объединить несколько массивов один список / массив - PullRequest
0 голосов
/ 15 октября 2019

Не могли бы вы подсказать, как объединить все перечисленные ниже атрибуты в один список / массив JSON?

{
        "results": [
            {
                "imdata": [
                    {
                        "l1PhysIf": {
                            "attributes": {
                                "dn": "topology/pod-1/node-1202/sys/phys",
                                "descr": ""
                            },
                            "children": [
                                {
                                    "ethpmPhysIf": {
                                        "attributes": {
                                            "operSt": "up"
                                        }
                                    }
                                }
                            ]
                        }
                    }
                ],
                "item": {
                    "fabricNode": {
                        "attributes": {
                            "dn": "topology/pod-1/node-1202",
                            "name": "NOQC"
                        }
                    }
                }
            }
        ]
    }

Я попробовал команду, как показано ниже. но, похоже, он не работает

{dn:results[*].imdata[*].l1PhysIf.attributes.dn, desc:results[*].imdata[*].l1PhysIf.attributes.descr,operSt:results[*].imdata[*].l1PhysIf.children[0].ethpmPhysIf.attributes.operSt, node:results[].item.fabricNode.attributes.dn,name:results[].item.fabricNode.attributes.name}

Но все атрибуты, входящие в отдельный массив, как показано ниже

{
  "dn": [
    [
      "topology/pod-1/node-1202/sys/phys"
    ]
  ],
  "desc": [
    [
      ""
    ]
  ],
  "operSt": [
    [
      "up"
    ]
  ],
  "node": [
    "topology/pod-1/node-1202"
  ],
  "name": [
    "NOQC"
  ]
}

Пожалуйста, найдите ниже ожидаемого результата: Пожалуйста, помогите

{ 
"result":[
  {
  "dn": "topology/pod-1/node-1202/sys/phys",
  "desc": "",
  "operSt": "up",
  "node": "topology/pod-1/node-1202",
  "name": "NOQC"
  }
  ]
}
...