【问题标题】:JoltTransformJSON processor in NiFiNiFi 中的 JoltTransformJSON 处理器
【发布时间】:2019-02-22 05:30:38
【问题描述】:

输入:

{ "table": [{
            "_id": {
              "personId": 1234,
              "customer": 345,
              "locale": "en"
          }} ] }

需要这种格式的输出,我的 Jolt Spec 应该是什么

{
"table": [{
          "personId": 1234,
          "customer": 345,
          "locale": "en"
}]
}

【问题讨论】:

    标签: json apache-nifi jolt


    【解决方案1】:

    试试下面的例子:

    [
      {
        "operation": "shift",
        "spec": {
          "table": {
            // table items
            "*": {
              // internal object in item under "_id" key
              "*": "table[]"
            }
          }
        }
      }
    ]
    

    【讨论】:

    • @user3533870,你确定吗?我已经使用online jolt 对其进行了测试。我使用了您的JSON payload 和我的transformation,它打印的结果与您想要的相同。
    • 对不起,它现在正在工作,我已经接受了你的回答。
    【解决方案2】:

    我找到了解决办法。

    [
      {
        "operation": "shift",
        "spec": {
          "*": {
            "*": {
              "_id": {
                "personId": "table[&2].personId",
                "customer": "table[&2].customer",
                "locale": "table[&2].locale"
              }
            }
          }
        }
      }
    ]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-21
      • 2018-08-11
      相关资源
      最近更新 更多