I have the following Json:
{
"Setting": {
"IsYear": true
},
"Durations": [
{
"Value": "100000000",
"Duration": 1
},
{
"Value": "100000001",
"Duration": 2
},
{
"Value": "100000002",
"Duration": 3
},
{
"Value": "100000003",
"Duration": 5
},
{
"Value": "100000004",
"Duration": 0
},
{
"Value": "100000005",
"Duration": 8
},
{
"Value": "100000006",
"Duration": 10
}
]
}
The class I have so far:
class Durations {
IsYear = false;
Durations = [];
}
And the deserialization:
let obj: MyObj = JSON.parse(jsonContent);
I'm actually struggling with deserializing and accessing the values in the resulting object.
Could please one show me how to properly deserialize the above json into the corresponding class with TypeScript and how to access the values?
Any help is highly appreciated.
interface Durations{ IsYear: boolean; Duration: number[]; }, and thenconst durations: Durations = JSON.parse(...)?