05-28-2023 09:57 PM
Hi there,
I have the following JSON
[
{
"POSEX":"00010",
"E1EDPT1": [
{
"E1EDPT2": [
{
"@SEGMENT": "1",
"TDLINE": "KIT,HIGH SPEED PINION (HSP),",
"TDFORMAT": "*"
},
{
"@SEGMENT": "1",
"TDLINE": "<br/>",
"TDFORMAT": "/"
}
]
},
{
"E1EDPT2": [
{
"@SEGMENT": "1",
"TDLINE": "*NSK bearings ",
"TDFORMAT": "*"
},
{
"@SEGMENT": "1",
"TDLINE": "STF*"
}
]
}
]
},
{
"POSEX":"00020",
"E1EDPT1": {
"@SEGMENT": "1",
"E1EDPT2": [
{
"@SEGMENT": "1",
"TDFORMAT": "*"
},
{
"@SEGMENT": "1",
"TDLINE": "<br/>",
"TDFORMAT": "/"
},
{
"@SEGMENT": "1",
"TDLINE": "MATERIAL DESCRIPTION :REVERSING",
"TDFORMAT": "/"
}
]
}
}
]
And expecting following
[
{
"order-lines": [
{
"line-num": "00010",
"attachments": [
{
"text": "KIT,HIGH SPEED PINION (HSP),<br/>"
},
{
"text": "*NSK bearings STF*"
}
]
},
{
"line-num": "00020",
"attachments": [
{
"text": ",<br/>,MATERIAL DESCRIPTION :REVERSING "
}
]
}
]
}
]
I tried to build following pipeline and is not working
toArray_2023_05_29.slp (13.4 KB)
it works fine for following
[
{
"POSEX":"00010",
"E1EDPT1": {
"@SEGMENT": "1",
"E1EDPT2": [
{
"@SEGMENT": "1",
"TDFORMAT": "*"
},
{
"@SEGMENT": "1",
"TDLINE": "<br/>",
"TDFORMAT": "/"
},
{
"@SEGMENT": "1",
"TDLINE": "MATERIAL DESCRIPTION :REVERSING CONTACTOR, SOLID STATE",
"TDFORMAT": "/"
}
]
}
},
{
"POSEX":"00020",
"E1EDPT1": {
"@SEGMENT": "1",
"E1EDPT2": [
{
"@SEGMENT": "1",
"TDFORMAT": "*"
},
{
"@SEGMENT": "1",
"TDLINE": "<br/>",
"TDFORMAT": "/"
},
{
"@SEGMENT": "1",
"TDLINE": "MATERIAL DESCRIPTION :REVERSING ",
"TDFORMAT": "/"
}
]
}
}
]
and gets what expected
[
{
"order-lines": [
{
"line-num": "00010",
"attachments": [
{
"text": ",<br/>,MATERIAL DESCRIPTION :REVERSING CONTACTOR, SOLID STATE"
}
]
},
{
"line-num": "00020",
"attachments": [
{
"text": ",<br/>,MATERIAL DESCRIPTION :REVERSING "
}
]
}
]
}
]
Any help in fixing the pipeline
Solved! Go to Solution.
05-29-2023 12:38 AM
I created this expression that supports both object and array if that’s how the external system is sending data to Snaplogic. This will work, give it a try. You can do a little fine-tuning to this.
Let me know if this works.
toArray_2023_05_29 (1).slp (7.4 KB)
Cheers,
05-28-2023 10:52 PM
Hey Manohar,
I noticed that in the first payload, there is an issue with the format, it’s inconsistent. The second payload is consistent and hence it’s working fine.
Can you confirm, if the first payload is not a typo? Let me know
05-29-2023 12:38 AM
I created this expression that supports both object and array if that’s how the external system is sending data to Snaplogic. This will work, give it a try. You can do a little fine-tuning to this.
Let me know if this works.
toArray_2023_05_29 (1).slp (7.4 KB)
Cheers,
05-29-2023 11:24 AM
hi thanks @Soni37,
Works like perfectly except for one thing, I need to add 2 static elements along with the text, I tried a few ways but was not able to add to it. can you point out on how to add that?
“type”:“AttachmentText”,
“intent”:“Supplier”,
[
{
"LINES": [
{
"POSEX": "00010",
"attachments": [
{
"type":"AttachmentText",
"intent":"Supplier",
"text": "KIT,HIGH SPEED PINION (HSP),,<br/>"
},
{
"type":"AttachmentText",
"intent":"Supplier",
"text": "*NSK bearings ,STF*"
}
]
},
{
"POSEX": "00020",
"attachments": [
{
"type":"AttachmentText",
"intent":"Supplier",
"text": ",<br/>,MATERIAL DESCRIPTION :REVERSING"
}
]
}
]
}
]
Thank you again for your help.
05-29-2023 04:21 PM
Hi @Soni37, please ignore it. I got it. Thank you again.