03-01-2023 04:23 PM
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
any guidance on how I can achieve it?
Thanks
Manohar
Solved! Go to Solution.
03-02-2023 06:33 AM
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.
03-02-2023 05:30 AM
@AleksandarAngelevski @bojanvelevski , any suggestions?
Thanks
Manohar
03-02-2023 05:37 AM
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.
03-02-2023 05:56 AM
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
03-02-2023 06:33 AM
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.