给定我的 JSON
countries: [
{country: "canada",
capital: "ottawa",
territories: [
yukon: {
capital: "yellowknife",
...
}
...
]
...
}
]
如何获取 yukon
的引用例如对象?
我想要类似的东西
yukon = countries[0].territories[0]
然后对 yukon
进行编辑这将反射(reflect)在原始 JSON 中。例如,
yukon.size = 1123300;
最佳答案
你已经成功了一半
var yukon = countries[0].territories[0].yukon;
yukon.size = 1123300;
关于javascript - 如何获取 JSON 对象的引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27633392/