I have a JSON with the following structure -
{
"gridDefinition": {},
"zoneDefinitions": [
{
"status": "Pending",
"name": "xxx-1",
"globalName": "xxx-2",
"id": 10,
"memory": "1234",
"cores": "0",
"VM": [
{
"ipAddress": "1.2.3.4",
"hostname": "zzzzz-1"
},
{
"ipAddress": "2.3.4.5",
"type": "virtual"
}
]
}
]
}
I need to parse this and display on the console, with the same structure but without all the "[]" and "{}" .
Something like:
gridDefinition:
zoneDefinitions:
Status:Pending
name:xxx-1
id:10
memory:1234
cores:0
VM:
ipAddress : 1.2.3.4
hostname : zzzzz-1
ipAddress:2.3.4.5
.......
.........
.............
I tried a couple of recursive solutions mentioned on pretty printing json
But this didn't work out.
There could be any levels of nesting of arrays and dictionaries, I need to preserve the indentation and print them on the console.
Could anybody guide me how to proceed with this?