{
"Id": null,
"productType": {
"productname": "abc",
"productPrice": ""
}
}
How to convert above JSON to array of Product?
{
"Id": null,
"product": [{
"productType": {
"productname": "abc",
"productPrice": ""
}
}]
}
Is this actually a TS question? Not really sure what's really being asked, here.
But if by "how to convert" you mean as a TS type:
original
type ProductType = { productName: string, productPrice: string }
type Product = { id: string, productType: ProductType }
after
type X = { id: string, product: ProductType[] }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.