在JOLT中执行cardinality-Many

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

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:

  1. {
  2. "PURCHASE_ORDER_DISPATCH": {
  3. "MsgData": {
  4. "Transaction": {
  5. "PSCAMA": {
  6. "PUBLISH_RULE_ID": {
  7. "IsChanged": "Y"
  8. }
  9. },
  10. "PO_POD_HDR_EVW1": {
  11. "STATE_BILL": "",
  12. "CURRENCY_CD": {
  13. "IsChanged": "Y",
  14. "content": "USD"
  15. },
  16. "ADDRESS4_VNDR": "",
  17. "PO_POD_LN_EVW1": {
  18. "WG_ACCOUNT": 641100,
  19. "LINE_NBR": {
  20. "IsChanged": "Y",
  21. "content": 1
  22. },
  23. "ITM_ID_VNDR": "B0798CX2Q9",
  24. "PO_POD_SHP_EVW1": {
  25. "LINE_NBR": {
  26. "IsChanged": "Y",
  27. "content": 1
  28. }
  29. }
  30. },
  31. "WG_ADDR_SEQ_NUM": 1
  32. }
  33. }
  34. }
  35. }
  36. }

JOLT Spec:

  1. {
  2. "operation": "cardinality",
  3. "spec": {
  4. "PURCHASE_ORDER_DISPATCH": {
  5. "MsgData": {
  6. "Transaction": {
  7. "PO_POD_HDR_EVW1": "MANY"
  8. }
  9. }
  10. }
  11. }
  12. }

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 :

  1. {
  2. "PURCHASE_ORDER_DISPATCH": {
  3. "MsgData": {
  4. "Transaction": {
  5. "PSCAMA": {
  6. "PUBLISH_RULE_ID": {
  7. "IsChanged": "Y"
  8. }
  9. },
  10. "PO_POD_HDR_EVW1": {
  11. "STATE_BILL": "",
  12. "CURRENCY_CD": {
  13. "IsChanged": "Y",
  14. "content": "USD"
  15. },
  16. "ADDRESS4_VNDR": "",
  17. "PO_POD_LN_EVW1": {
  18. "WG_ACCOUNT": 641100,
  19. "LINE_NBR": {
  20. "IsChanged": "Y",
  21. "content": 1
  22. },
  23. "ITM_ID_VNDR": "B0798CX2Q9",
  24. "PO_POD_SHP_EVW1": {
  25. "LINE_NBR": {
  26. "IsChanged": "Y",
  27. "content": 1
  28. }
  29. }
  30. },
  31. "WG_ADDR_SEQ_NUM": 1
  32. }
  33. }
  34. }
  35. }
  36. }

JOLT Spec :

  1. {
  2. "operation": "cardinality",
  3. "spec": {
  4. "PURCHASE_ORDER_DISPATCH": {
  5. "MsgData": {
  6. "Transaction": {
  7. "PO_POD_HDR_EVW1": "MANY"
  8. }
  9. }
  10. }
  11. }
  12. }

Getting this error: Failed to Transform

答案1

得分: 1

  1. [
  2. {
  3. "operation": "cardinality",
  4. "spec": {
  5. "PURCHASE_ORDER_DISPATCH": {
  6. "MsgData": {
  7. "Transaction": {
  8. "PO_POD_HDR_EVW1": "MANY"
  9. }
  10. }
  11. }
  12. }
  13. }
  14. ]
英文:

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

Try this:

  1. [
  2. {
  3. "operation": "cardinality",
  4. "spec": {
  5. "PURCHASE_ORDER_DISPATCH": {
  6. "MsgData": {
  7. "Transaction": {
  8. "PO_POD_HDR_EVW1": "MANY"
  9. }
  10. }
  11. }
  12. }
  13. }
  14. ]

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:

确定