简体   繁体   中英

Not able to Convert Array of Json to Flattern Json Using Jolt (V0.1.1)

Input payload:

{
  "accountNo":112233,
  "type":"DEDICATED",
  "Plans" : {
     "One":"Basic",
     "Two":"Mid",
     "Three":"Premium"  
   },

  "Address": {
     "Primary":{
       "Addressline1":" road 1, boss lane",
      "AddressLine2": "ST",
    "City":"Tex"
    }
  }

}

Expected PayLoad:

{
  "accountNo":112233,
  "type":"DEDICATED",
  "One":"Basic",
  "Two":"Mid",
  "Three":"Premium",
  "Addressline1":" road 1, boss lane",
  "AddressLine2": "ST",
  "City":"Tex"
}

Used Jolt v0.1.1 not able to convert, could anyone help me out

Check this spec,

[
  {
    "operation": "shift",
    "spec": {
      "accountNo": "accountNo",
      "type": "type",
      "Plans": {
        "One": "One",
        "Two": "Two",
        "Three": "Three"
      },
      "Address": {
        "Primary": {
          "Addressline1": "Addressline1",
          "AddressLine2": "AddressLine2",
          "City": "City"
        }
      }
    }
  }
]

You can individually evaluate the expression by seperating into the conditional branches of Plans , Address.Primary and * for the rest( non-nested ) of the elements within a shift transformation such as

[
  {
    "operation": "shift",
    "spec": {
      "Plans": {
        "*": "&"
      },
      "Address": {
        "Primary": {
          "*": "&"
        }
      },
      "*": {
        "@": "&"
      }
    }
  }
]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM