json 要显示从对象数组中获取的属性,请在Jolt Transform中展平

vvppvyoh  于 2023-08-08  发布在  其他
关注(0)|答案(1)|浏览(106)

我有低于震动的输入,

{
  "citycode": "34343",
  "branch": "cityname",
  "changeDatetime": 1677063272522,
  "Marks": "L",
  "designations": [
    {
      "designation": "security ",
      "Language": "de"
    },
    {
      "designation": "officer",
      "Language": "fr"
    },
    {
      "designation": "superior",
      "Language": "en"
    }
  ]
}

字符串
所需输出为:

{
  "citycode" : "34343",
  "branch" : "cityname",
  "Marks" : "L",
  "LANGUAGE-ID" :  "de", 
  "Occupation" : "security",
  "LANGUAGE-ID" :  "fr",
  "Occupation" : "officer",
  "LANGUAGE-ID" : "en",
  "Occupation" : "superior"
}


电流冲击输出如下:

{
  "citycode" : "34343",
  "branch" : "cityname",
  "Marks" : "L",
  "LANGUAGE-ID" : [ "de", "fr", "en" ],
  "Occupation" : [ "security ", "officer", "superior" ]
}


需要分别拆分数组元素。你能帮帮忙吗

cgfeq70w

cgfeq70w1#

当前所需的JSON输出无效,但您可能需要以下输出

[
  {
    "operation": "shift",
    "spec": {
      "*": "&", // all elements other than the "designations" array
      "designations": {
        "*": { // loop through the indexes of the "designations" array
          "L*": "LANGUAGE-ID_&1",
          "d*": "Occupation_&1"
        }
      }
    }
  }
]

字符串
它为每个LANGUAGE-IDOccupation键添加增量(0,1,2)索引后缀

相关问题