【问题标题】:Convert JSON Object [duplicate]转换 JSON 对象 [重复]
【发布时间】:2014-05-07 10:34:48
【问题描述】:

我有一个 Json 对象,例如,

{"Id":1492,"name":"Antony","School":"National School"}

现在我需要分离这些对象。我想得到这样的东西,

Id = 1492
name = Antony
School = National School

所以我需要将这些数据单独存储在 db 表中。

请帮忙。

非常感谢

【问题讨论】:

    标签: java json


    【解决方案1】:

    使用 http://code.google.com/p/json-simple/

    JSONObject json = (JSONObject)new JSONParser().parse("{\"Id\":1492,\"name\":\"Antony\",\"School\":\"National School\"}");
    System.out.println("id=" + json.get("Id"));
    System.out.println("name=" + json.get("name"));
    

    【讨论】:

      【解决方案2】:

      希望对你有所帮助-

        var data = '{"Id":1492,"name":"Antony","School":"National School"}';
        var json = JSON.parse(data);
      
        var Id = json["Id"];
      

        var Id = json.Id;
      

      【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-07-26
      • 2015-01-02
      • 1970-01-01
      • 2020-11-02
      • 2020-11-07
      • 1970-01-01
      • 1970-01-01
      • 2016-08-26
      相关资源
      最近更新 更多