I need to loop through a REST response object, which has an object with objects. I am on ES5 javascript, and cannot change how the data is served.
This is for a ServiceNow script include, which is in javascript es5. for...of is not available. I have tried a for...in loop with the object, but I just get what each object is called(truncation). I need to loop through the "Objects" object in my code example code.
{
"formatVersion": "v1.0",
"someText": "Text",
"someDate": "2019-11-08T18:51:37Z",
"Objects": {
"NestedObj1": {
"prop1": "val1",
"prop2": "val2",
"prop3": "val3",
},
"NestedObj2": {
"prop1": "val4",
"prop2": "val5",
"prop3": "val6",
}
}
}
I need to loop through a database insert. When the above JSON is converted to object, expecting something such as: for(var obj in someObjName.Objects) and then reference each property (the property names don't change) via obj.prop1.