1

是否可以使用 JOLT SPEC 将值映射到键。我的输入Json

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

Output Json as 

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

请为上述场景提供 Json SPEC

4

1 回答 1

7

输入

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

规格

[
  {
    "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"
    }
  }
]
于 2017-03-17T04:37:49.330 回答