我正在尝试从json数组中获取json对象作为列表。以下是我的json示例,我从js函数动态生成并将其存储在id json变量中。
[{
"id": "0f0ae12842ab4870a76f082a67236469",
"date": "2019-12-12T05:00:23.182Z",
"key": "43894"
},
{
"id": "0c19b022242b4a27ab1b47a46605a9ca",
"date": "2019-12-12T05:00:23.182Z",
"key": "93476"
},
{
"id": "19b27546a77f4210bd5764e350515b90",
"date": "2019-12-12T05:00:23.182Z",
"key": "93476"
},
{
"id": "0715c43653c94a8b8d91dcc1646c04d5",
"date": "2019-12-12T05:00:23.182Z",
"key": "93476"
},
{
"id": "1ea75688810d49089b06dc787f9dc586",
"date": "2019-12-12T05:00:23.182Z",
"key": "93476"
}]
//Output: Should be list of objects outside array.
{
"id": "0f0ae12842ab4870a76f082a67236469",
"date": "2019-12-12T05:00:23.182Z",
"key": "43894"
},
{
"id": "0c19b022242b4a27ab1b47a46605a9ca",
"date": "2019-12-12T05:00:23.182Z",
"key": "93476"
},
{
"id": "19b27546a77f4210bd5764e350515b90",
"date": "2019-12-12T05:00:23.182Z",
"key": "93476"
},
{
"id": "0715c43653c94a8b8d91dcc1646c04d5",
"date": "2019-12-12T05:00:23.182Z",
"key": "93476"
},
{
"id": "1ea75688810d49089b06dc787f9dc586",
"date": "2019-12-12T05:00:23.182Z",
"key": "93476"
}
我正在尝试使用此功能: json temp = id [*]; //我得到的数组与上面的元素列表相同 我也尝试过: json temp = get [*] id; //与上面相同
我需要它作为数组外部对象的列表,以便可以设置为另一个json变量。
答案 0 :(得分:0)
只需执行以下操作:
* def temp = id[0]