JS Access JSON Reference code
"Content-type"Content="text/html; CHARSET=GBK"/> <script type="Text/javascript">varSmstypedesc = {"4":"Return SMS","3":"Email SMS","AA":"Test SMS"}; function Enumakey () { for(varKeyinchSmstypedesc) {alert (key); }} function Getval () {varKey = Prompt ("Please enter the key to query","4"); if("undefined"==typeof(SMSTYPEDESC))return; if("undefined"==typeof(Smstypedesc[key])) {Alert ("input key:"+key+", it does not exist in the JSON object! "); return; } alert ("The key you entered is:"+key +", the value corresponding to this key is:"+Smstypedesc[key]); } function Getvalbykey () {alert (SMSTYPEDESC.AA); } </script> JSON object:<br/> <pre>varSmstypedesc = {"4":"Return SMS","3":"Email SMS","AA":"Test SMS"}; </pre> <input type="Button"onclick="Enumakey ();"Value="traverse Smstypedesc All keys"/> <input type="Button"onclick="getval ();"Value="gets the value of the SMSTYPEDESC dynamic specified key"/> <input type="Button"onclick="Getvalbykey ();"Value="gets the value corresponding to the SMSTYPEDESC key AA"/> </body>The above code can see that the value of JS access JSON is mainly through the "key" "value" way to access,
Excerpted from http://blog.csdn.net/love__coder/article/details/7532616