<script type="text/javascript"> getJson('age'); function getJson(key){ var jsonObj={"name":"傅红雪","age":"24","profession":"刺客"}; //1.使用eval方法 var eValue=eval('jsonObj.'+key); alert
1.JSON字符串注意事项:key和value都要用双引号,官网指定用双引号,如下: var mapStr='{"a":"a","b":"b"}'; var map=JSON.parse(mapStr); 如此通过拼接字符串,JSON解析获得KeyValue var str='a'; map[str];//输出a 2.也是通过拼接字符串方式获得keyvalue,使用eval方法解析成数组,注意是数组 var mapStr='[
源码: /* http://www.JSON.org/json2.js 2010-03-20 Public Domain. NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK. See http://www.JSON.org/js.html This code should be minified before deployment. See http://javascript.crockford.com/jsmin.html USE Y