码迷,mamicode.com
首页 > Web开发 > 详细

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

时间:2017-03-24 13:24:18      阅读:244      评论:0      收藏:0      [点我收藏+]

标签:ast   class   ons   javascrip   sci   blog   UI   master   off   

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

 

局限性都比较大

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

标签:ast   class   ons   javascrip   sci   blog   UI   master   off   

原文地址:http://www.cnblogs.com/toSeeMyDream/p/6610876.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!