欢迎访问悦橙教程(wld5.com),关注java教程。悦橙教程  java问答|  每日更新
页面导航 : > > > 文章正文

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

来源: javaer 分享于  点击 29387 次 点评:274

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


var 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


局限性都比较大

相关文章

    暂无相关文章

用户点评