cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Route based on grand child value

manohar
Contributor

Hi there, I have this structure json. I need to route the json based on attachment in below json, if exist or not

input json

[
  {
    "data": {
      "po-number": "4501918519_2",
      "order-lines": [
        {
          "id": {
            "@type": "integer",
            "$": "40950"
          },
          "attachments": {
            "@type": "array"
          }
        },
        {
          "id": {
            "@type": "integer",
            "$": "40951"
          },
          "attachments": {
            "@type": "array",
            "***attachment**":* {
              "id": {
                "@type": "integer",
                "$": "1884472"
              },
              "type": "AttachmentText",
              "intent": "Supplier",
              "text": "SURGE TRAP 600V"
            }
          }
        }
      ]
    },
    "headerid": "16825",
    "IDOC": {
      "@BEGIN": "1",
      "EDI_DC40": {
        "DOCNUM": "0000000046984396"
      }
    },
    "Origattachments": [
      {
        "type": "AttachmentText",
        "intent": "Supplier",
        "text": "test"
      }
    ]
  }
]

my needed outputs
output 1 -

[
  {
    "data": {
      "po-number": "4501918519_2",
      "order-lines": [
        {
          "id": {
            "@type": "integer",
            "$": "40950"
          },
          "attachments": {
            "@type": "array"
          }
        }
      ]
    },
    "headerid": "16825",
    "IDOC": {
      "@BEGIN": "1",
      "EDI_DC40": {
        "DOCNUM": "0000000046984396"
      }
    },
    "Origattachments": [
      {
        "type": "AttachmentText",
        "intent": "Supplier",
        "text": "test"
      }
    ]
  }
]

output 2

[
  {
    "data": {
      "po-number": "4501918519_2",
      "order-lines": [
        {
          "id": {
            "@type": "integer",
            "$": "40951"
          },
          "attachments": {
            "@type": "array",
            "attachment": {
              "id": {
                "@type": "integer",
                "$": "1884472"
              },
              "type": "AttachmentText",
              "intent": "Supplier",
              "text": "SURGE TRAP 600VDC"
            }
          }
        }
      ]
    },
    "headerid": "16825",
    "IDOC": {
      "@BEGIN": "1",
      "EDI_DC40": {
        "DOCNUM": "0000000046984396"
      }
    },
    "Origattachments": [
      {
        "type": "AttachmentText",
        "intent": "Supplier",
        "text": "test"
      }
    ]
  }
]

input json structure pic
image

any guidance on how I can achieve it?

Thanks
Manohar

1 ACCEPTED SOLUTION

So you want every order line to be as a separate object, or you want two objects:

  • Object A: with order lines that contain ***attachment***

  • Object B: with order lines that doesnโ€™t

SL-comm-route-based-on-grand-child_2023_03_02.slp (7.6 KB)
This pipeline creates as many objects, as there are in the order-lines array under data.

View solution in original post

5 REPLIES 5

manohar
Contributor

@AleksandarAngelevski @bojanvelevski , any suggestions?

Thanks
Manohar

Hi @manohar.

Can you provide more clarification about what you are trying to achieve?

As far as I understand from the given input and outputs you are just splitting the order-lines array including the parents properties.

Hi @AleksandarAngelevski , thats right. based on attachment exist or not exist in attachments, I need to split from all the way top, just what you said

@AleksandarAngelevski corrected ^^

Thanks
Manohar

So you want every order line to be as a separate object, or you want two objects:

  • Object A: with order lines that contain ***attachment***

  • Object B: with order lines that doesnโ€™t

SL-comm-route-based-on-grand-child_2023_03_02.slp (7.6 KB)
This pipeline creates as many objects, as there are in the order-lines array under data.