1
私はfollow(json2)として再帰的なjsonツリーをトラバースし、別のjson(json)とマージします。 オブジェクトが利用可能な場合は、オブジェクトまたはオブジェクトがありますが、その識別子がどのようにオブジェクトの同じ階層にあるかは任意です。トラバース再帰的jsonツリーとマージ
注:識別子の値が常に一意
である私はunderscore.jsライブラリをウォークスルーしているが、この要件に適合する機能のいずれかを見つける傾けます。通常のリストの場合、findWhereは解決するには十分でしょうが、複数の階層構造を持つため、これは当てはまりません。
JSON 2:
{
"identifier1": "123456",
"identifier2": "234567"
}
JSON 1:
{
subtopic: [
{
"title": "title 1",
"subtitle": "title 2",
"objects": [{
"title": "123"
"label": "456"
"objects": [
{
"identifier": "identifier1",
"object": {
"object-1": "123",
"object-2": "456"
}
},
{
"identifier": "identifier2",
"object": {
"object-1": "123",
"object-2": "456"
}
}
]
}]
},
{
...
...
Similar as above
},
]
}
{
subtopic: [
{
"title": "title 1",
"subtitle": "title 2",
"objects": [{
"title": "123"
"label": "456"
"objects": [
{
"result": "123456",
"identifier": "identifier1",
"object": {
"object-1": "123",
"object-2": "456"
}
},
{
"result": "234567"
"identifier": "identifier2",
"object": {
"object-1": "123",
"object-2": "456"
}
}
]
}]
},
{
...
...
Similar as above
},
]
}