将JSON对象中的嵌套数组的数据转换或格式化为绑定Kendo网格的Typescript中的嵌套JSON对象

问题描述 投票:0回答:1

我一直在尝试将JSON对象中的嵌套数组的数据转换为Typescript中的嵌套JSON对象。这是从REST API返回的数据,因为输入了打字稿:

嵌套数组包含方括号。

data={
    "ID":29614,"Ratio":8,"UOM":"IN",
    "manufacturers":[{
        "manufacturerName":john,
        "categories":[{
            "categoryName":Beverage,
            "products":[{"uid":"456","productID":140721,"name":"After Shocks Popping Candy 1.06 
                ]}
            ]}
        ]}
    }

我需要的格式是:

data=[{
    "ID":29614,"Ratio":8,"UOM":"IN",
    "manufacturers":{
    "manufacturerName":john,
    "categories":{
    "categoryName":Beverage,
    "products":{"uid":"456","productID":140721,"name":"After Shocks Popping Candy 1.06 
            }
        }
    }
}]

输出嵌套数组应删除方括号。

我已经尝试过]

`public gridData:any [];绑定剑道网格的gridData

return this.restApi.getProductBin().subscribe((data: {}) => {this.gridData = Array.of(data); //convert to array}

我一直在尝试将JSON对象中的嵌套数组的数据转换为Typescript中的嵌套JSON对象。这是从rest api返回的数据,当输入打字稿时:嵌套数组包含正方形...

json angular typescript kendo-grid webapi
1个回答
0
投票

尝试这样:

© www.soinside.com 2019 - 2024. All rights reserved.