我想删除所有嵌套数组,并将"Location"和"metaRecords"的值放入rest json对象中,最后删除这些对象("Location"和"metaRecords").
{
"info": [
{
"item": "sugar",
"price": 4,
"state": "Alberta",
"country": "Canada"
},
{
"item": "sugar",
"price": 4.5,
"state": "California",
"country": "US"
}
],
"location": {
"continent": [
{
"country": "US",
"coordinates": {
"lang": "97º 00' W",
"long": "38º 00' N"
}
},
{
"country": "Canada",
"coordinates": {
"lang": "95° 00' W",
"long": "60° 00' N"
}
}
]
},
"metarecord": {
"continent": "North America"
}
}
以下是我想要实现的目标: 删除所有嵌套数组,并使用Country的值将"Location"的值放入其相应的json对象中(例如,如果对象的Country值是"Canada",则应添加"Canada"的位置),而"metaRecords"是对"info"中的所有对象的常规设置
[
{
"continent": "North America",
"item": "sugar",
"price": 4,
"state": "Alberta",
"country": "Canada",
"lang": "95° 00' W",
"long": "60° 00' N"
},
{
"continent": "North America",
"item": "sugar",
"price": 4.5,
"state": "California",
"country": "US",
"lang": "97º 00' W",
"long": "38º 00' N"
}
]
我try 了什么:
[
{
"operation": "shift",
"spec": {
"info": {
"*": {
"item": "[&1].item",
"price": "[&1].price",
"state": "[&1].state",
"country": "[&1].country"
}
},
"location": {
"continent": {
"@": "[&1].continent"
}
},
"metarecord": {
"continent": {
"*": {
"$": "[&2].&1"
}
}
}
}
}
]
输出:这不是我想要的.
[
{
"item": "sugar",
"price": 4,
"state": "Alberta",
"country": "Canada"
},
{
"item": "sugar",
"price": 4.5,
"state": "California",
"country": "US"
}
]