prathik vijaykumar
prathik vijaykumar

Reputation: 395

Convert flat json to nested json using jolt transform

The input json :

{
  "key1": "value1",
  "key2": "value2",
  "key3": "value3",
  "key4": "value4"
}

The expected output:

{
  "key1" : "value1",
  "Name" : {
    "key2" : "value2",
    "key3" : "value3",
    "key4" : "value4"
  }
}

I would like to have a jolt transform, which can nest few fields.

Upvotes: 0

Views: 185

Answers (1)

Barbaros Özhan
Barbaros Özhan

Reputation: 65408

You just need a shift transformation with a conditional logic: picking key1 and the rest of the attributes("*") such as

[
  {
    "operation": "shift",
    "spec": {
      "key1": "&",
      "*": "Name.&"
    }
  }
]

the demo on the site http://jolt-demo.appspot.com/

enter image description here

Upvotes: 1

Related Questions