First: Object Mode
<Script type = "text/javascript">
// 1. First, the json format must be written in this way, although this is only one of the methods.
Var json = {"options": "[{\" text \ ": \" wangjiawan \ ", \" value \ ": \" 9 \"}, {\ "text \": \ "Li jiawan \", \ "value \": \ "10 \" },{ \ "text \": \ "Shao jiawan \", \ "value \": \ "13 \"}] "}
Json = eval (json. options) // note options. If you do not write Options, the following method is json. options. length.
For (var I = 0; I <json. length; I ++)
{
Alert (json [I]. text + "" + json [I]. value) // access
}
</Script>
Second: Array
<Script type = "text/javascript">
// 1. First, the json format must be written in this way, although this is only one of the methods.
Var json = "[\" 1 \ ", \" 2 \ "]"
// 2. Access
Json = eval (json)
Alert (json [0]); // 1
Alert (json [1]); // 2
</Script>
I would like to share with you a few places to learn JSON:
Chinese official introduction:
Http://www.json.org/json-zh.html
Microsoft introduction:
Http://msdn.microsoft.com/zh-cn/library/bb299886.aspx
IBM introduction:
Http://www.ibm.com/developerworks/cn/web/wa-ajaxintro/