JSONオブジェクトのネストされた配列のデータをTypescriptのネストされたJSONオブジェクトに変換しようとしています。これは、typescript を取得する際の 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
}