Mah*_*oud 2 java parsing android json
我有一个Json数组作为字符串没有名称,我想解析它我怎么能在android中做到这一点?
我的JsonArray是:
[
{
"categoryId":1,
"Title":"Rock",
"songs":null
},
{
"categoryId":2,
"Title":"Jaz",
"songs":null
}
]
Run Code Online (Sandbox Code Playgroud)
Har*_*ran 11
试试这个..
JSONArray jsonarray = new JSONArray(json);
for (int i = 0; i < jsonarray.length(); i++) {
JSONObject jsonobj = jsonarray.getJSONObject(i);
System.out.println("categoryId : " + i + " = " + jsonobj.getString("categoryId"));
System.out.println("Title : " + i + " = " + jsonobj.getString("Title"));
System.out.println("songs : " + i + " = " + jsonobj.getString("songs"));
}
Run Code Online (Sandbox Code Playgroud)