在JOLT中执行cardinality-Many

huangapple go评论60阅读模式
英文:

Perform cardinality-Many in JOLT

问题

I want to write a Jolt definition using cardinality - MANY that can transform object "PO_POD_LN_EVW1" into a list and ignore it if it's already a list.

Input JSON:

{
  "PURCHASE_ORDER_DISPATCH": {
    "MsgData": {
      "Transaction": {
        "PSCAMA": {
          "PUBLISH_RULE_ID": {
            "IsChanged": "Y"
          }
        },
        "PO_POD_HDR_EVW1": {
          "STATE_BILL": "",
          "CURRENCY_CD": {
            "IsChanged": "Y",
            "content": "USD"
          },
          "ADDRESS4_VNDR": "",
          "PO_POD_LN_EVW1": {
            "WG_ACCOUNT": 641100,
            "LINE_NBR": {
              "IsChanged": "Y",
              "content": 1
            },
            "ITM_ID_VNDR": "B0798CX2Q9",
            "PO_POD_SHP_EVW1": {
              "LINE_NBR": {
                "IsChanged": "Y",
                "content": 1
              }
            }
          },
          "WG_ADDR_SEQ_NUM": 1
        }
      }
    }
  }
}

JOLT Spec:

{
  "operation": "cardinality",
  "spec": {
    "PURCHASE_ORDER_DISPATCH": {
      "MsgData": {
        "Transaction": {
          "PO_POD_HDR_EVW1": "MANY"
        }
      }
    }
  }
}

Getting this error: Failed to Transform

英文:

I want to write a Jolt definition using cardinality - MANY that can transform object "PO_POD_LN_EVW1" into list and ignore if its already a list.

Input JSON :

{
  "PURCHASE_ORDER_DISPATCH": {
    "MsgData": {
      "Transaction": {
        "PSCAMA": {
          "PUBLISH_RULE_ID": {
            "IsChanged": "Y"
          }
        },
        "PO_POD_HDR_EVW1": {
          "STATE_BILL": "",
          "CURRENCY_CD": {
            "IsChanged": "Y",
            "content": "USD"
          },
          "ADDRESS4_VNDR": "",
          "PO_POD_LN_EVW1": {
            "WG_ACCOUNT": 641100,
            "LINE_NBR": {
              "IsChanged": "Y",
              "content": 1
            },
            "ITM_ID_VNDR": "B0798CX2Q9",
            "PO_POD_SHP_EVW1": {
              "LINE_NBR": {
                "IsChanged": "Y",
                "content": 1
              }
            }
          },
          "WG_ADDR_SEQ_NUM": 1
        }
      }
    }
  }
}

JOLT Spec :

{
  "operation": "cardinality",
  "spec": {
    "PURCHASE_ORDER_DISPATCH": {
      "MsgData": {
        "Transaction": {
          "PO_POD_HDR_EVW1": "MANY"
        }
      }
    }
  }
}

Getting this error: Failed to Transform

答案1

得分: 1

[
  {
    "operation": "cardinality",
    "spec": {
      "PURCHASE_ORDER_DISPATCH": {
        "MsgData": {
          "Transaction": {
            "PO_POD_HDR_EVW1": "MANY"
          }
        }
      }
    }
  }
]
英文:

Your jolt spec is correct, But You should wrap all of your specs in the [] array.

Try this:

[
  {
    "operation": "cardinality",
    "spec": {
      "PURCHASE_ORDER_DISPATCH": {
        "MsgData": {
          "Transaction": {
            "PO_POD_HDR_EVW1": "MANY"
          }
        }
      }
    }
  }
]

huangapple
  • 本文由 发表于 2023年2月16日 19:04:07
  • 转载请务必保留本文链接:https://go.coder-hub.com/75471338.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定