0
我有此JSON模式,我想分析只有一個目標:解析一個JSONObject
{"CodeMsg": "Server Local Time", "server_time": "2012-03-19 19:59:30", "CodeResult": "OK"}
我怎麼能這樣做?
我有此JSON模式,我想分析只有一個目標:解析一個JSONObject
{"CodeMsg": "Server Local Time", "server_time": "2012-03-19 19:59:30", "CodeResult": "OK"}
我怎麼能這樣做?
有許多庫可用於解析JSON。通常使用的兩個是:
GSON - http://code.google.com/p/google-gson/
- 傑克遜http://jackson.codehaus.org/
隨着雙方你這樣做:
它們非常易於使用。
var data = {"CodeMsg": "Server Local Time", "server_time": "2012-03-19 19:59:30", "CodeResult": "OK"};
JSONObject obj1 = new JSONObject(data);
and then use obj1.getJSONString('CodeMsg');