I am new to javascript. I have a json data which I need to process using javascript.
{
"results":
{
"Karnataka":
{
"state_results":
{
"population":
{
"totalRecords": 0,
"content":
[
],
"id": null
},
"male_count":
{
"totalRecords": 0,
"content":
[
],
"id": null
},
"female_count":
{
"totalRecords": 0,
"content":
[
],
"id": null
}
},
"district_results":
{
"links":
[
],
"totalRecords": 5,
"content":
[
{
"districtName": "Davanagere",
"population": 1232323213213,
"area": "123123123 Sq Kms",
},
{
"districtName": "Tumkur",
"population": 1232323213213,
"area": "123123123 Sq Kms",
},
{
"districtName": "Dharwar",
"population": 1232323213213,
"area": "123123123 Sq Kms",
},
{
"districtName": "Mangalore",
"population": 1232323213213,
"area": "123123123 Sq Kms",
},
{
"districtName": "Bagalkot",
"population": 1232323213213,
"area": "123123123 Sq Kms",
},
],
"id": null
}
},
"Kerala":
{
"state_results":
{
"population":
{
"totalRecords": 0,
"content":
[
],
"id": null
},
"male_count":
{
"totalRecords": 0,
"content":
[
],
"id": null
},
"female_count":
{
"totalRecords": 0,
"content":
[
],
"id": null
}
},
"district_results":
{
"links":
[
],
"totalRecords": 5,
"content":
[
{
"districtName": "Davanagere",
"population": 1232323213213,
"area": "123123123 Sq Kms",
},
{
"districtName": "Tumkur",
"population": 1232323213213,
"area": "123123123 Sq Kms",
},
{
"districtName": "Dharwar",
"population": 1232323213213,
"area": "123123123 Sq Kms",
},
{
"districtName": "Mangalore",
"population": 1232323213213,
"area": "123123123 Sq Kms",
},
{
"districtName": "Bagalkot",
"population": 1232323213213,
"area": "123123123 Sq Kms",
},
],
"id": null
}
}
}
}
I need to write a recursive function to traverse through the json and get the inner objects which contain the content section which has data. How do I write a recursive function using javascript?