Can someone assist me with the following JSON problem?
{
"loanDetails": [
{
"vehicleDetail": {
"RCBookImageReferences": {
"imagePathReferences": [
{
}
]
}
},
"chargeDetails": [
{
}
],
"commissionDetails": [
{
}
],
"disbursementDetails": [
{
}
]
}
] } In the above JSON, I am looking to iterate through each key and if it's empty, then set the parent as an empty array. The desired output is:
{"loanDetails":[]}
I tried using the code snippet below:
function isEmpty(obj) {
for(var prop in obj) {
if(obj.hasOwnProperty(prop))
return false;
}
return true;
}
However, this code did not give me the expected result. I seem to be stuck at this point. Any help will be greatly appreciated.