如何访问此嵌套 javascript 对象中的嵌套键?
我有以下 javascript 对象:
result = {
"banking6dig":{
"GM-B-001":{
"releaseDate":"2/2/2012 14:44","noOfHex":"3","versInfo":"6 digit Banking"
},
"GM-B-002":{
"releaseDate":"1/2/2012 14:46","noOfHex":"3","versInfo":"6 digit Banking with changes"
}
},
"paynpark":[]
}
说明:
“banking6dig”和“paynpark”是应用程序
“banking6dig”有两个颠覆:“GM-B-001”和“GM-B-002”
“paynpark”没有颠覆。
此外,每个子版本都有自己的属性,即“releaseDate”、“noOfHex”和“versInfo”。
这个对象“结果”是在 php 请求之后构建的,因此它可以有任意数量的应用程序和子版本;但格式始终相同。
我在 jsFiddle 上尝试过: http://jsfiddle.net/2JLtZ/1/
- 我该怎么办找出每个“应用程序”中的“颠覆”数量? (我得到了大约 40 个“颠覆”!)
- 如何将应用程序添加到对象“结果”,例如“电力”并重置其属性?
- 如何向“paynpark”添加颠覆,例如“fixedRate”?
- 如何修改颠覆属性,例如将“GM-B-001”的“releaseDate”更改为“3/12/2012 14:46”?
I have the following javascript object:
result = {
"banking6dig":{
"GM-B-001":{
"releaseDate":"2/2/2012 14:44","noOfHex":"3","versInfo":"6 digit Banking"
},
"GM-B-002":{
"releaseDate":"1/2/2012 14:46","noOfHex":"3","versInfo":"6 digit Banking with changes"
}
},
"paynpark":[]
}
Explanation:
"banking6dig" and "paynpark" are applications
"banking6dig" has two subversions : "GM-B-001" and "GM-B-002"
"paynpark" has no subversions.
Additionally, each subversion has its own properties,viz, "releaseDate", "noOfHex", and "versInfo".
This object "result" is built after a php request, so it can have any number of apps and subversions; the format, however is ALWAYS the same.
I have tried this on jsFiddle: http://jsfiddle.net/2JLtZ/1/
- How do I find out the number of "subversions" in each "app"? (I get some 40 "subversions"!)
- How do I add an app to the object "result", e.g., "electricity" with its properties reset?
- How do I add a subversion to "paynpark", e.g. "fixedRate"?
- How do I modify a subversions properties, for example change "releaseDate" of "GM-B-001" to "3/12/2012 14:46"?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
1.2.3
.
感谢
AlienWebguy 指出了这一点。
4.
1.
2.
3.
Thanks AlienWebguy for pointing this out.
4.
演示:http://jsfiddle.net/AlienWebguy/DpCTP/
Demo: http://jsfiddle.net/AlienWebguy/DpCTP/