Iterate Nested Object based on each Index

  Kiến thức lập trình

Below “NodeClassification” having nested object in each object having there item objects which I need to break this to form array of object. Result of array of object as shown below to from a structure with new key & existing values.

JSON Object Structure:
    "NodeClassification": {
             "MobileCore": {
                "NORMAL": {
                   "DownCount": 2
                },
                "VIP": {
                   "DownCount": 2
                }
             },
             "MobileRAN": {
                "NORMAL": {
                   "DownCount": 4
                },
                 "VIP": {
                       "DownCount": 4
                    },
                "CRITICAL": {
                       "DownCount": 4
                    }
             }
          }
        
    Result I need based on Array Of Object Structure:
    [{
        group: 'NORMAL',
        key: 'Mobile',
        value: 2
      },
      {
        group: 'VIP',
        key: 'Mobile',
        value: 2
      },
      {
        group: 'NORMAL',
        key: 'MobileRAN',
        value: 4
      },
      {
        group: 'VIP',
        key: 'MobileRAN',
        value: 4
      },
      {
        group: 'CRITICAL',
        key: 'MobileRAN',
        value: 4
      }
    ] 

LEAVE A COMMENT