After retrieving data from the JSON file, I start by creating a class and defining all the variables obtained in the JSON for strict data typing. For example, my JSON file looks like this:
{"fname":"Mark","lname":"jhony"}
In Angular, I define the class as follows:
export class user{
fname: string;
lname : string;
}
However, I am facing confusion on how to structure the class for the following JSON data:
{"fname":"Mark","lname":"jhony",
"parcels":[
{
"parcelId":123,
"parcelName":"asd",
"parcelItems:[
{
"itemId":2,
"itemName":"perfume"
},
{
"itemId":4,
"itemName":"soap"
}
]
]}
I have attempted to include arrays in the class but I am struggling to determine the best approach to handle it in AngularJS.