【问题标题】:How to compare filed values in JOLT transformation?如何比较 JOLT 转换中的字段值?
【发布时间】:2019-03-08 11:09:11
【问题描述】:

我有如下输入,

输入:

{
  "a": 1,
  "b": 2
}

规格:

[
 {
  "operation": "shift",
  "spec": {
    "a": {
      "@(2,b)": {
        "#Matched": "result"
      },
      "*": {
        "#Not Matched": "result"
      }
    }
  }
}]

输出:

{
 "result" : [ "Matched", "Not Matched" ]
}

预期:

{
 "result" : "Not Matched" 
}

谁能建议我照常工作。

【问题讨论】:

    标签: json transformation jolt


    【解决方案1】:

    你可以分三步改造它:

    1. 将值移动到键
    2. 找到匹配的键
    3. 如果未找到匹配的键,则添加“不匹配”结果

    (无法想象为什么它不适用于值)

    像这样的:

    [
      {
        "operation": "shift",
        "spec": {
          "*": "&.@0"
        }
      },
      {
        "operation": "shift",
        "spec": {
          "a": {
            "*": {
              "@(2,b.&)": {
                "#Matched": "result"
              }
            }
          }
        }
      },
      {
        "operation": "default",
        "spec": {
          "result": "Not Matched"
        }
      }
    ]
    

    【讨论】:

      猜你喜欢
      • 2022-08-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-10-01
      • 1970-01-01
      相关资源
      最近更新 更多