I have following json generated by my website. I’m completely new with android programming. If possible tell me how to parse following json data to display in listview.
JSON:
{
"Category":[
{
"id":"14",
"parent_id":"2",
"lft":"3",
"rght":"18",
"name":"Category Name",
"icon":"",
"created":"2012-04-21 23:43:37",
"modified":"2012-04-21 23:43:37"
},
{
"id":"15",
"parent_id":"2",
"lft":"19",
"rght":"28",
"name":"Category Name",
"icon":"",
"created":"2012-04-21 23:44:10",
"modified":"2012-04-21 23:44:10"
},
{
"id":"16",
"parent_id":"2",
"lft":"29",
"rght":"34",
"name":"Category Name",
"icon":"",
"created":"2012-04-21 23:44:35",
"modified":"2012-04-21 23:45:37"
},
{
"id":"17",
"parent_id":"2",
"lft":"35",
"rght":"60",
"name":"Category Name",
"icon":"",
"created":"2012-04-21 23:44:52",
"modified":"2012-04-21 23:45:53"
},
{
"id":"18",
"parent_id":"2",
"lft":"61",
"rght":"62",
"name":"Category Name",
"icon":"",
"created":"2012-04-21 23:46:05",
"modified":"2012-04-21 23:46:05"
},
{
"id":"19",
"parent_id":"2",
"lft":"63",
"rght":"70",
"name":"Category Name",
"icon":"",
"created":"2012-04-21 23:46:19",
"modified":"2012-04-21 23:46:19"
}
],
"success":1
}
Get the json array and get individual nested objects and arrays inside it one by one. Then use get(String key) method to get the value of individual strings inside the objects.
In your case, the code would be: