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