재귀 적으로 모든 JSON 객체를 가져옵니다

하자 treeData = [

    {
        "ID" (9601),
        "의 DeviceID" "99a9014e-a651-43ce-945c-c027e6235ab4",
        "장치 이름" "测试设备名称",
        "DeviceBrand" NULL,
        "DeviceTypeId" NULL,
        "DeviceLevel" 1 ,
        "FactorySerial" "CS010",
        "CompanySerial" "CS010",
        "FModelSize" NULL,
        "칠더스": [
            {
                "ID" 9603,
                "의 DeviceID" "271b8edb-f836-49a6-a99a-09148a0547ea" ,
                "장치 이름": "测试设备名称_1",
                "DeviceBrand"널 (null),
                "DeviceTypeId" 널 (null),
                "DeviceLevel": 2,
                "FactorySerial": "CEMC1"
                "CompanySerial" "CEMC1",
                "FModelSize" NULL,
                "칠더스" [

                ]
            }
        ]
    },
    {
        "ID" 9604,
        "의 DeviceID" "18b6e21b-07aa-432D-843a-0f106b088b88",
        "장치 이름" : "测试의 USB",
        "DeviceBrand" NULL,
        "DeviceTypeId" NULL,
        "DeviceLevel" 1
        "FactorySerial" "U_1",
        "CompanySerial" "U_1",
        "FModelSize" NULL,
        "칠더스"[
            {
                "ID" (9602),
                "의 DeviceID" "8c7081b5-67ae-4ef9-b150-524bbd2b81f9"
                "장치 이름" "测试设备名称",
                "DeviceBrand" NULL,
                "DeviceTypeId" NULL,
                "DeviceLevel" 2
                "FactorySerial" "CS010",
                "CompanySerial" "CS011",
                "FModelSize" NULL,
                "칠더스": [
                    {
                        "ID" 9607,
                        "의 DeviceID" "56a25da2-6e22-4c0d-9f99-79fed4ee9546",
                        "장치 이름" "测试设备名称_1",
                        "DeviceBrand" NULL,
                        "DeviceTypeId" 널 (null),
                        "DeviceLevel": 3,
                        "FactorySerial""U_4",
                        "CompanySerial" "U_4",
                        "FModelSize" NULL,
                        "칠더스" [

                        ]
                    }
                ]
            }
        ]
    }
]
새로운 배열을 재귀 모든 JSON 푸시
getTree (treeData) {
  {(나는 ++; 나는 <treeData.length I = 0하자) 미국
    this.dataInfoList.push (treeData [I])
    경우 (treeData [I] .Childers && treeData [I] .Childers.length> 0) {
      this.getTree (treeData [I] .Childers)
    }
  }
},
 CONSOLE.LOG (this.dataInfoList)

 

 

모든 장비 © 2014 JSON.cn

추천

출처www.cnblogs.com/wgy0528/p/11362983.html