Fight With Me!!!

导航

json转字符串 —— jsonObj.toJSONString()与JSON.stringify(jsonObj)

ar people = { "programmers": [{ "firstName": "Brett", "lastName": "McLaughlin", "email": "aaaa" }, { "firstName": "Jason", "lastName": "Hunter", "email": "bbbb" }, { "firstName": "Elliotte", "lastName": "Harold", "email": "cccc"}],  
    "authors": [{ "firstName": "Isaac", "lastName": "Asimov", "genre": "science fiction" }, { "firstName": "Tad", "lastName": "Williams", "genre": "fantasy" }, { "firstName": "Frank", "lastName": "Peretti", "genre": "christian fiction"}],  
    "musicians": [{ "firstName": "Eric", "lastName": "Clapton", "instrument": "guitar" }, { "firstName": "Sergei", "lastName": "Rachmaninoff", "instrument": "piano"}]  
};  
alert(JSON.stringify(people));  

  

 

 

上面的, 只能在IE8或者以上, Firefox下运行

 

toJSONString() , 必须要引入

https://github.com/douglascrockford/JSON-js/blob/master/json.js

 

局限性都比较大

posted on 2017-03-24 12:28  nickTimer  阅读(1486)  评论(0编辑  收藏  举报