Here is my JSON data :
{
"main": [
{
"main_id": "1234",
"main_sub": [
{
"main_info": {
"main_1" : "A",
"main_2" : "B",
"main_3" : "C"
},
"main_4" : "D",
"main_5" : "E",
},
{
"main_6" : "F",
"main_7" : "G",
"main_info": {
"main_1" : "H",
"main_2" : "I",
"main_3" : "J"
},
"main_4" : "D",
"main_5" : "E",
"main_act": [
{
"main_act_1": 12,
"main_act_1_1": "C",
"main_act_1_2": "T"
},
{
"main_act_1": 12,
"main_act_1_1": "D",
"main_act_1_2": "T"
}
],
"main_8" : "R"
},
{
"main_4" : "D",
"main_5" : "E",
"main_10": "P"
}
],
"main_score": 0.1
},
{
"main_id": "1334",
"main_sub": [
{
"main_info": {
"main_1" : "B",
"main_2" : "Q",
"main_3" : "C",
"main_11": "D"
},
"main_4" : "S",
"main_5" : "E",
"main_6" : "G",
"main_7" : "T"
},
{
"main_6" : "F",
"main_7" : "G",
"main_info": {
"main_1" : "A",
"main_2" : "I",
"main_3" : "J"
},
"main_10": "W",
"main_4" : "D",
"main_5" : "E",
"main_act": [
{
"main_act_1": 112,
"main_act_1_1": "C",
"main_act_1_2": "T"
},
{
"main_act_1": 123,
"main_act_1_1": "D",
"main_act_1_2": "T"
}
],
"main_8" : "R"
},
{
"main_4" : "D",
"main_5" : "E",
"main_10": "P"
}
],
"main_score": 0.1
}
],
"main_count": 2
}
I am not able to read a large part of this data due to the nesting even after I use $.each in jQuery.
Also is there a way by which I could read every single line of this json data and print it on screen without actually mentioning the field names like "main_1" in my jQuery code ?
Output Expected :
I would just want to print the field names as well as well as their values for each of the two instances of main .
Somewhat like :
main_id - 1234
main_sub -
main_info -
main_1 - A
main_2 - B
and so on.................. (for both instances of main - thus the main_count = 2 at the end of the json data)
$.each
to parse this json.