我有一个这样的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"
}
]资源/所有者/引用类型< -> /id >。对于每辆车,要添加到json中的车主名称。我尝试了各种组合,但都做不到。
任何帮助都将不胜感激。
发布于 2019-02-22 09:38:01
这并不意味着要这么做。它用于Json的结构化格式更改,而不是数据依赖的更改。
也就是说,我从后端系统中获取Json,它总是以"A“格式返回,并且我需要始终以"B”格式返回它,而不管实际数据是什么。
https://stackoverflow.com/questions/54502431
复制相似问题