开发者

Reading JSON Name and Value

I want to read JSON objects's name value pair. Sample JSON below:

{"menu": {
  "id": "file",
  "value": "File",
  "popup": {
    "**menuitem开发者_如何学编程**": [
      {"**value**": "New", "**onclick**": "CreateNewDoc()"},
      {"value": "Open", "onclick": "OpenDoc()"},
      {"value": "Close", "onclick": "CloseDoc()"}
    ]
  }
}

As an example, if I want to read name "menuitem" and its values "value", "onclick". How is "menuitem" referred in this context?


menu.popup.menuitem[0].value

menu.popup.menuitem[0].onclick

(you could also run through a loop if you wanted to get something rather than the first menuitem)

I assume there was asterisks in your code because you were trying to bold the sections in the json that you wanted to retrieve?

Also that json isn't valid, you're missing a closing }

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜