I'm just trying to read json objects from a json array. But I'm getting [Object]
in place of nested Json objects while trying to read the whole array.
My JSON looks like this:
var json = {
"root_id": [
{
"child-id1": {
"name": "name1",
"created_by": null,
"created_at": "2018-05-30T19:34:38.657Z",
"configs": {
"generic": {
"size": 1000,
"timeout": 60,
"field1_key": "field1_value"
},
"specific": {
"key1": "xxx-xxx",
"field1_key": "field1_value"
}
}
}
},
{
"child-id2": {
"name": "name2",
"created_by": null,
"created_at": "2018-05-30T19:34:38.657Z",
"configs": {
"generic": {
"size": 10,
"timeout": 60,
"field1_key": "field1_value"
},
"specific": {
"key1": "xxx-xxx",
"field1_key": "field1_value"
}
}
}
}
]
}
I want my function return the Json array of "root_id" object. So, I just tried this simple code to read the array:
var val = json['root_id'];
console.log(val);
But it returns this:
[ { 'child-id1':
{ name: 'name1',
created_by: null,
created_at: '2018-05-30T19:34:38.657Z',
configs: [Object] } },
{ 'child-id2':
{ name: 'name2',
created_by: null,
created_at: '2018-05-30T19:34:38.657Z',
configs: [Object] } } ]
How do i make sure the nested objects return as it is instead of just [object]?