I know this has probably been asked a million times but I spent the whole day and I cannot resolve my problem. So here it is. I have a json object in the following format.
So I am trying to loop through this json object but just cannot be able to do. I simply can get iy working. For example:
const json = [
[{
"Id": 1,
"Name": "Jeffreys Bay",
"ProvinceID": 1
}, {
"Id": 2,
"Name": "Heidelberg",
"ProvinceID": 3
}]
]
for (let x in json) {
console.log(x + ': ' + json[x]);
}
returns
core.js:6479 ERROR SyntaxError: Unexpected token o in JSON at position 1
at JSON.parse (<anonymous>)
at SafeSubscriber._next (location.page.ts:71)
at SafeSubscriber.__tryOrUnsub (Subscriber.js:183)
at SafeSubscriber.next (Subscriber.js:122)
at Subscriber._next (Subscriber.js:72)
at Subscriber.next (Subscriber.js:49)
at MapSubscriber._next (map.js:35)
at MapSubscriber.next (Subscriber.js:49)
at FilterSubscriber._next (filter.js:33)
at FilterSubscriber.next (Subscriber.js:49)
Please help me??