3

Is it possible to map a value to a key using JOLT SPEC. MY input Json

{
  "name": "Rj",
  "Age" : "15"
}

Output Json as 

{
  "Rj" : {
    "Age":"15"
  }
}

Please provide a Json SPEC for above scenario

Milo S
  • 4,466
  • 1
  • 19
  • 22
user6543599
  • 541
  • 2
  • 8
  • 18

1 Answers1

9

Input

{
    "name": "Rj",
    "Age": "15"
}

Spec

[
  {
    "operation": "shift",
    "spec": {
      // @(1,name) -> go up 2 level, come back down and 
      //  grab the value at "name" which is "RJ"
      // Thus this evaluates to 
      // "Age" : "RJ.Age"
      "Age": "@(1,name).Age"
    }
  }
]
Milo S
  • 4,466
  • 1
  • 19
  • 22
  • 1
    Hi Milo. THANK YOU so much.. Is it possible to create SPEC for an output like this { "key" : {"value of object"}} – user6543599 Mar 17 '17 at 04:42