如何获取多个数组值作为对象

时间:2015-09-22 06:24:29

标签: json jolt

您好我是JOLT转型的新手。我需要使用JOLT转换输入json以获得下面看到的输出。请帮我改造:

[
{
   "image": "content1",
   "legal": "legal1",
   "hyper": "hyper1"
},
{
   "image": "content1",
   "legal": "legal1",
   "hyper": "hyper1"
},
{
   "image": "content1",
   "legal": "legal1",
   "hyper": "hyper1"
}
]

输出:

{{1}}

1 个答案:

答案 0 :(得分:1)

规格

[
  {
    "operation": "shift",
    "spec": {
      "*": { // image, legal, etc
        "*": { // array
          "*": { // content1, legal1, etc
            "$": "[&2].&3" // grab "content1" and use it as output
                 // send it to an output doc that is a top level array
                 // indexed by looking 3 levels up the tree [&2]
          }
        }
      }
    }
  }
]