Answer the question
In order to leave comments, you need to log in
How to parse JSON into objects?
[
{
"street": {
"id": 0,
"name": "string",
"type": {
"id": 0,
"name": "string"
},
"city": {
"id": 0,
"name": "string",
"type": {
"id": 0,
"name": "string"
}
}
},
"house": "string",
"id": 0
}
]
getLocalStorage(key: string) {
const myData = this.localStg.get(key);
this.house = JSON.parse(myData);
}
Answer the question
In order to leave comments, you need to log in
What is there localStg
? And the JSON itself is perfectly parsed.
const json = `[
{
"street": {
"id": 0,
"name": "string",
"type": {
"id": 0,
"name": "string"
},
"city": {
"id": 0,
"name": "string",
"type": {
"id": 0,
"name": "string"
}
}
},
"house": "string",
"id": 0
}
]`;
JSON.parse(json);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question