Re-parent a JSON object using Jolt

后端 未结 1 1943
隐瞒了意图╮
隐瞒了意图╮ 2021-01-28 02:46

I\'d like to move a JSON object down one level using Jolt. Here\'s my input data :

{
    \"rating\": {
        \"primary\": {
            \"value\": 3,
                


        
相关标签:
1条回答
  • 2021-01-28 03:03

    Spec

    [
      {
        "operation": "shift",
        "spec": {
          "@": "NEWPARENT"
        }
      }
    ]
    

    FYI, the "root" you are seeing is an artifact of the way that Jolt deals with the fact that the top level JSON input can be either a List or a Map, and that you want to be able to Transform a List into a Map (and vice versa).

    So, jolt "wraps" the input so that it is "always" transforming a Map that has a single key "root", with a value that is the input.

    0 讨论(0)
提交回复
热议问题