如何在JOLT中追加额外的字段列表?

时间:2016-10-04 13:37:53

标签: jolt

我正在尝试在列表中添加一些额外的字段,这些字段在输入json中不存在。我可以添加字段,如果它是一个对象,但我无法将字段添加到数组中。请有人帮我写一份规范。

input JOSN is:

[
    {
        "List": [
            {
                "ITEM_NO": "abcd"
            }
        ]
    }
]

写了一个spec文件

SPEC File is:

[
  {
    "operation": "shift",
    "spec": {
      "*": {
        "List": {
          "0": {
            "ITEM_NO": "risk[0].one"
          }
        }
      }
    }
  },
  {
    "operation": "default",
    "spec": {
      "risk": [{
        "two": "efgh",
        "three":"ijkl"
      }]
    }
  }
]

但输出并不像预期的那样

expeted output is:

{
  "risk" : [ {
    "one" : "abcd",
    "two":"efgh",
    "three":"ijkl"
  } ]
}

如何添加额外字段?

1 个答案:

答案 0 :(得分:3)

规格

[
  {
    "operation": "shift",
    "spec": {
      "*": {
        "List": {
          "0": {
            "ITEM_NO": "risk[0].one"
          }
        }
      }
    }
  },
  {
    "operation": "default",
    "spec": {
      "risk[]": {
        "0": {
          "two": "efgh",
          "three": "ijkl"
        }
      }
    }
  }
]

生成您想要的输出,但不确定您要执行的操作。