我一直在尝试将 JSON 对象中的嵌套数组数据转换为 Typescript 中的嵌套 JSON 对象。这是输入打字稿时从rest api返回的数据:
嵌套数组包含方括号。
data={ "ID":29614,"Ratio":8,"UOM":"IN", "manufacturers": [{ "manufacturerName": "john", "categories": [{ "categoryName": "Beverage", "products": [{ "uid": "567", "productID": 130927, "name": "After Shocks Popping Candy 1.06"}] }] } , { "manufacturerName": "Dan", "categories": [{ "categoryName": "Organization", "products": [{ "uid": "65", "productID": 5656, "name": "After Shocks Popping Candy 2.06"}] }] } ] }
Format I need is:
data=[{ "ID":29614,"Ratio":8,"UOM":"IN", "manufacturers": { "manufacturerName": "john", "categories": { "categoryName": "Beverage", "products": { "uid": "567", "productID": 130927, "name": "After Shocks Popping Candy 1.06"} } } , { "manufacturerName": "Dan", "categories": { "categoryName": "Organization", "products": { "uid": "65", "productID": 5656, "name`enter code here`": "After Shocks Popping Candy 2.06"} } } }]
Output nested array should remove square brackets.
I have tried this as
public gridData: any[];
//gridData for bind Kendo grid
return this.restApi.getProductBin().subscribe((data: {}) => {
this.gridData = Array.of(data); //convert to array
}