As a newcomer to Typescript, I want to create interfaces for the JSON data shown below:
{
"company":"abc inc",
"logoUrl":"someUrl",
"phone":"1234567890",
"branch":{
"nyc":{
"products":{
"asian":{
"somekey1":"someValue1",
"somekey2":"someValue2",
"somekeyN":"somevalueN"
},
"american":{
"somekey1":"someValue1",
"somekey2":"someValue2",
"somekeyN":"somevalueN"
}
}
},
"boston":{
"products":{
"asian":{
"somekey1":"somevalue1",
"somekey2":"somevalue2",
"somekeyN":"somevalueN"
},
"american":{
"somekey1":"somevalue1",
"somekey2":"somevalue2",
"somekeyN":"somevalueN"
}
}
}
}
}
I have defined interfaces for this structure, but I am stuck on how to properly define the asian
and american
objects with multiple key-value pairs. Can someone provide guidance on the correct syntax for this? Your help is much appreciated. Thank you.
interface Products {
asian: {};
american: {};
}
interface Configuration {
company: string;
phone: string;
logoUrl: string
branch: {
nyc: {
products: Products;
};
boston: {
products: Products;
};
};
}