Let be this JSON string:
[
{
"id": 1,
"text": "Jon Doe"
},
{
"id": 1,
"text": "Pablo Escobar"
}
]
Let be this class:
export class MyObject{
id: number;
text: string;
}
How can I cast this JSON string to list of MyObject
?
If I do:
console.log(<MyObject[]>JSON.parse(json_string));
It returns a list of Object
instead of a list of MyObject