我有 2 个 json 对象,每个对象都有我想加入的唯一 ID。
对象是:
main:
{"meta": {"limit": 100, "next": null, "offset": 0, "previous": null, "total_count": 1},
"objects": [{"name": "John", "date": "2013-02-25", "mid": "512bd2f0e1cb890007b0cbf1"}]}
mid
{"meta": {"limit": 20, "next": null, "offset": 0, "previous": null, "total_count": 1},
"objects": [{"id": "512bd2f0e1cb890007b0cbf1", "title": "My Fav"}]}
您如何将它们与 jquery 加入 1 个对象并获取相同的 id 是
where main.objects.mid = mid.objects.id
优选连接对象
newobject.
{"meta": {"limit": 100, "next": null, "offset": 0, "previous": null, "total_count": 1}, "objects": [{"name": "John", "date": "2013-02-25", "mid": "512bd2f0e1cb890007b0cbf1"
"mid": {title": "My Fav"}}
}]}
如果您注意到,只需将数据中间对象附加到主标题中。