我有一个这样的json,
{
"entry": [
{
"resource": {
"id": "car-1",
"type": "vehicle",
"color": "red",
"owner": {
"ref": "Person/person-1"
}
}
},
{
"resource": {
"id": "car-2",
"type": "vehicle",
"color": "blue",
"owner": {
"ref": "Person/person-2"
}
}
},
{
"resource": {
"id": "person-1",
"type": "Person",
"name": "john"
}
},
{
"resource": {
"id": "person-2",
"type": "Person",
"name": "wick"
}
}
]
}
并希望将其转换为类似的东西。
[
{
"id": "car-1",
"type": "vehicle",
"color": "red",
"ownername": "john"
},
{
"id": "car-2",
"type": "vehicle",
"color": "blue",
"ownername": "wick"
}
]
资源/ owner / ref - > <type / id>。对于每辆车,所有者名称将被添加到json中。我尝试了各种组合,但无法做到。
任何帮助将不胜感激。
这并不意味着那样做。它适用于Json的结构格式更改,而不是数据相关的更改。
即我从后端系统中获取Json,它始终采用格式“A”,并且我需要始终以格式“B”返回它,无论数据实际是什么。