Convert JSON data list string to object list in TypeScript
To convert a JSON data list string to a list of objects in TypeScript, you can use the parse() method of the JSON object. For example, I have a list of classes returned from the backend as a GraphQL response as follows:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
const response: any = `{ "data": { "clazzes": [ { "id": "1", "name": "A1" }, { "id": "2", "name": "A2" }, { "id": "3", "name": "B1" }, { "id": "4", "name": "B2" } ] } }`; |
On the… Read More







