2014-03-28 153 views
-2

我有一个JSON对象一样,转换JSON对象

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

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

Id = 1492 
name = Antony 
School = National School 

因此,我需要将这些数据分别存储在数据库表中。

请帮忙。

感谢很多

+0

使用GSON库 –

回答

0

使用 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")); 
0

希望这将有助于你 -

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

    var Id = json["Id"]; 

var Id = json.Id; 
+0

钍是针对Java的。 –

+0

对不起,你可以在这里找到你的答案http://stackoverflow.com/questions/7451600/jsonobject-how-to-get-a-value –