json 转变成 string方法介绍:

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

局限性都比较大

 

相关文章:

  • 2022-12-23
  • 2021-12-27
  • 2022-12-23
  • 2022-02-07
  • 2021-06-13
  • 2022-02-21
  • 2021-12-09
  • 2022-02-07
猜你喜欢
  • 2022-12-23
  • 2021-11-21
  • 2022-12-23
  • 2021-10-21
  • 2021-10-31
相关资源
相似解决方案