【发布时间】:2015-11-16 13:27:54
【问题描述】:
我正在尝试合并一些 json。我试过these answers,但我认为它们不符合我的需求。
我有 2 个(或更多)这些 jsons
{
item: {
icon: "http://services.runescape.com/m=itemdb_rs/4922_obj_sprite.gif?id=2",
icon_large: "http://services.runescape.com/m=itemdb_rs/4922_obj_big.gif?id=2",
id: 2,
type: "Default",
typeIcon: "http://www.runescape.com/img/categories/Default",
name: "Cannonball",
description: "Ammo for the Dwarf Cannon.",
current: {
trend: "neutral",
price: 208
},
today: {
trend: "positive",
price: "+8"
},
members: "true",
day30: {
trend: "positive",
change: "+8.0%"
},
day90: {
trend: "negative",
change: "-4.0%"
},
day180: {
trend: "positive",
change: "+9.0%"
}
}
}
如何将它们添加到这样的东西中?
{
items: [
{
icon: "http://services.runescape.com/m=itemdb_rs/4922_obj_sprite.gif?id=2",
icon_large: "http://services.runescape.com/m=itemdb_rs/4922_obj_big.gif?id=2",
id: 2,
type: "Default",
typeIcon: "http://www.runescape.com/img/categories/Default",
name: "Cannonball",
description: "Ammo for the Dwarf Cannon.",
//Same other stuff here
},
{
icon: "http://services.runescape.com/m=itemdb_rs/4922_obj_sprite.gif?id=2",
icon_large: "http://services.runescape.com/m=itemdb_rs/4922_obj_big.gif?id=2",
id: 2,
type: "Default",
typeIcon: "http://www.runescape.com/img/categories/Default",
name: "Cannonball",
description: "Ammo for the Dwarf Cannon.",
//Same other stuff here
}
]
}
【问题讨论】:
-
@AlexAndrei 我尝试了链接中的答案和一些接近他们的答案。第一个给了我NULL,第二个给了我尝试合并的最后一个json。
-
不知何故错过了你的第一句话,抱歉。您能否发布所有 json 字符串,或者我可以复制第一个字符串吗?
-
生成的 json 应该是什么样子
-
@dlporter98 喜欢底部的json
-
请不要将答案编辑到您的问题中。选择对您有帮助的答案并将其标记为已接受,或发布您自己的答案并接受。