这是我的 JSON 对象,我想在 android 项目中解析它
{
"second": {
"versionInfo": "0.20.3-dev",
"compileDate": "Mon Mar 12 17:39:23 IST 2012",
"compileUser": "suraj",
"trackname": "tracker_localhost:localhost/127.0.0.1:48418"
},
"href": {
"versionInfo": "null",
"compileDate": "null",
"compileUser": "null",
"trackname": "null"
},
"first": {
"key": "['trackname','versionInfo','compileDate','compileUser']"
}
}
如何编译?
我想首先提取“第一个”的属性并使用这些属性,然后使用“第一个”的属性提取“第二个”的参数。
基本上是这样完成的:
JSONObject jobj = new JSONObject(theString);
JSONObject first = jobj.getJSONObject("first");
JSONObject second = jobj.getJSONObject("second");
如果您想要更多,请查看文档Android 的 JSON 类 http://developer.android.com/reference/org/json/package-summary.html.
Edit
关于数组的提取(在first->key中):
String jStr = first.getString("key");
JSONArray jArr = new JSONArray(jStr);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)