zoukankan      html  css  js  c++  java
  • json转字符串 —— jsonObj.toJSONString()与JSON.stringify(jsonObj)json to string

     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

    局限性都比较大

  • 相关阅读:
    MFC列表控件更改一行的字体颜色
    MFC之sqlite
    MFC笔记10
    MFC---关于string.h相关函数
    MFC笔记8
    MFC笔记7
    MFC笔记6
    MFC笔记5
    MFC笔记4
    MFC笔记3
  • 原文地址:https://www.cnblogs.com/wolfocme110/p/4000469.html
Copyright © 2011-2022 走看看