【问题标题】:Not able to Convert Array of Json to Flattern Json Using Jolt (V0.1.1)无法使用 Jolt (V0.1.1) 将 Json 数组转换为 Flattern Json
【发布时间】:2021-05-21 15:42:19
【问题描述】:

输入负载:

{
  "accountNo":112233,
  "type":"DEDICATED",
  "Plans" : {
     "One":"Basic",
     "Two":"Mid",
     "Three":"Premium"  
   },

  "Address": {
     "Primary":{
       "Addressline1":" road 1, boss lane",
      "AddressLine2": "ST",
    "City":"Tex"
    }
  }

}

预期有效载荷:

{
  "accountNo":112233,
  "type":"DEDICATED",
  "One":"Basic",
  "Two":"Mid",
  "Three":"Premium",
  "Addressline1":" road 1, boss lane",
  "AddressLine2": "ST",
  "City":"Tex"
}

使用 Jolt v0.1.1 无法转换,谁能帮帮我

【问题讨论】:

    标签: java arrays json apache-nifi jolt


    【解决方案1】:

    对于 中的其余元素(非嵌套),您可以通过将条件分支分隔为 PlansAddress.Primary* 来单独评估表达式shift变换如

    [
      {
        "operation": "shift",
        "spec": {
          "Plans": {
            "*": "&"
          },
          "Address": {
            "Primary": {
              "*": "&"
            }
          },
          "*": {
            "@": "&"
          }
        }
      }
    ]
    

    【讨论】:

    • 是否有任何工具可以生成基于规范的输入 Json?
    • 嗨@Shivak,网上有个著名的playground
    【解决方案2】:

    检查此规范,

    [
      {
        "operation": "shift",
        "spec": {
          "accountNo": "accountNo",
          "type": "type",
          "Plans": {
            "One": "One",
            "Two": "Two",
            "Three": "Three"
          },
          "Address": {
            "Primary": {
              "Addressline1": "Addressline1",
              "AddressLine2": "AddressLine2",
              "City": "City"
            }
          }
        }
      }
    ]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-01-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多