I have a large json object that looks like this:
{
"item1": {
"key1": "val1",
"key2": "val2",
"key3": [
"val4",
"val5",
]
},
{
"item2": {
"key1": "val1",
"key2": "val2",
"key3": [
"val3",
"val4",
]
}
... etc ...
}
I created an interface:
interface MyObj {
key1: string;
key2: string;
key3: string[];
}
Then try to parse the json:
const myObj[]: {string: Myobj[]} = JSON.parse(response);
But I get the error SyntaxError: Unexpected token o in JSON at position 1. I have checked response in a json validator and it passes.
I want to parse response into an array of MyObj.
key3is not an object, it's array right? how you are getting data in key-value pair inside array?responseis not a well formed JSON.