【问题标题】:Using JOLT Transformation Need to remove the sqaure brakets of an object使用 JOLT Transformation 需要去掉一个对象的方括号
【发布时间】:2022-11-28 20:00:38
【问题描述】:

我正在尝试使用 JOLT 转换从 JSON 数组中删除一个字段。下面是输入 JSON 和预期的输出 JSON。

你能为上述场景建议 JOLT 转换吗

输入:

{
  "code": 200,
  "data": {
    "totalCount": 1,
    "SCount": 1,
    "FCount": 0,
    "FSequences": [],
    "token": [
      328358
    ]
  },
  "id": "ce27g26hvamob9lbd0eg"
}

颠簸我正在使用:

[
  {
    "operation": "shift",
    "spec": {
      "data": {
        "*": "&"
      },
      "status|id": "&"
    }
  }
]

预期输出:

{
  "totalCount" : 1,
  "SCount" : 1,
  "FCount" : 0,
  "FSequences" : "",
  "token" : "328358",
  "status" : 200,
  "id" : "ce27g26hvamob9lbd0eg"
}

【问题讨论】:

    标签: json apache-nifi jolt


    【解决方案1】:

    你可以使用这个规范

    [
      {
        "operation": "shift",
        "spec": {
          "data": {
            "*": "&",
            "token": {
              "*": "&1" // replicates the tag "token" by grabbing after going up tree one level
            }
          },
          "code": "status", // renaming the attribute
          "id": "&"
        }
      },
      {
        "operation": "modify-overwrite-beta",
        "spec": {
          "*u*n*": ["=toInteger", ""] // conversion only doesn't apply for "FSequences" among *u*n* tagged attributes
        }
      }
    ]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-08-03
      • 2020-12-13
      • 2012-10-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多