I have an array of objects, like so:
var arr = [{request: {funding : 123, id: 123abc, membership: true},
response: {funding : 285, success: true }},
{request: {funding : 123, id: 123def, membership: true},
response: {funding : 167, success: true }},
{request: {funding : 123, id: 123def, membership: true},
response: {funding : 234, success: true }}]
I am attempting to convert the nested objects into strings for a CSV parsing program however when using the following code:
for (var item in arr)
{ item.response = JSON.stringify(item.response);
item.request = JSON.stringify(item.request);
}
after checking typeof(item.response) for an item in my array, i still get returned object.
However, if I manually set the property of the individual item, outside a for loop, it appears to work as intended.
e.g.
arr[0].response = JSON.stringify(arr[0].response)
typeof(arr[0].response) // string