json 如何在jolt中更改数组的第二个值

bq3bfh9z  于 2022-12-15  发布在  其他
关注(0)|答案(1)|浏览(130)

数值输入

“项目内部ID”:[“01”、“02”、“011055000000345”]

预期值输出

“项目内部ID”:[“01”、“16”、“011055000000345”]
Jolt只有两个函数,"lastElement""firstElement",所以我在Internet上找不到修改第二个值的任何内容

bpsygsoo

bpsygsoo1#

不需要使用具有这些函数的modify转换,而是使用shift转换规范以及相应组件的索引,例如

[
  {
    "operation": "shift",
    "spec": {
      "*": { //stands for "ItemInternalId"
        "1": { // the level of the second component of the array in which index starts from zero
          "#16": "&2" // the fixed value might be assigned by prepending the value with "#" on the left-hand-side, &2 represents going the tree two levels up to grab the tag of the array
        },
        "*": "&1"//else case. The &1 on the right-hand-side represents going the tree one level up to grab the tag of the array
      }
    }
  }
]

假设您的输入是

{
  "ItemInternalId": [
    "01",
    "02",
    "011055000000345"
  ]
}

http://jolt-demo.appspot.com/站点上的***演示***是

相关问题