Here is json which i have to parse
{"opcode":"groupdetails",
"status":"success",
"data":[{"Group ID":5,"Group Name":"data structure","Group Subject":"computer science","Role Type":"Teacher"},{"Group ID":4,"Group Name":"information technology","Group Subject":"computer science","Role Type":"Student"},{"Group ID":6,"Group Name":"data mining","Group Subject":"computer science","Role Type":"Parent"},{"Group ID":7,"Group Name":"dccn","Group Subject":"computer science","Role Type":"Teacher"}]}
i have tried and implemented the solution provided here in SO.
here is the implementation of JS that defined there in solution, which parses only JSON array
for (var i = 0; i < data.data.length; i++)
{
var object = data.data[i];
for (property in object)
{
var value = object[property];
alert(property + "=" + value);
}
}
the outer data is json returned from server
and yes i have tried parsing using the following code and there is no Result
for (var i = 0; i < data.length; i++)
{
var object = data[i];
for (property in object)
{
var value = object[property];
alert(property + "=" + value);
}
}
Question is how to parse entire json using single method instead of parsing JSONArray seprately