cancel
Showing results for 
Search instead for 
Did you mean: 

JSON Root value

walkermic
New Contributor III

I have an IDOC listener that will receive json files of different formats. The root of the json file will be different for the different types. I need to evaluate the root value(PEXR2002 in this example) and then route it based on the value to other child pipelines. I cannot figure out how to get the value out. Anyone know?
{
“PEXR2002”: {
“IDOC”: {
@BEGIN”: “1”,
“EDI_DC40”: {
@SEGMENT”: “1”,
“TABNAM”: “EDI_DC40”,
“MANDT”: “100”,
“DOCNUM”: “0000000002472008”,
“DOCREL”: “731”,
“STATUS”: “30”,
“DIRECT”: “1”,
“OUTMOD”: “2”,
“IDOCTYP”: “PEXR2002”,
“MESTYP”: “PAYEXT”,
“STDMES”: “PAYEXT”,
“SNDPOR”: “SAPS41”,
“SNDPRT”: “LS”,
“SNDPRN”: “S41CLNT100”,
“RCVPOR”: “SNAPLOGIC”,
“RCVPRT”: “LS”,
“RCVPRN”: “SNAPLOGIC”,
“CREDAT”: “20181205”,
“CRETIM”: “220141”,
“SERIAL”: “20180917101221”
},
“E1IDKU1”: {
@SEGMENT”: “1”,
“BGMTYP”: “PEX”,
“BGMNAME”: “EXTENDED PAYMENT ORDER”,
“BGMREF”: “2000000796”,
“BGMLEV”: “ORG”,
“BGMACC”: “001”
},
“E1EDK03”: [
{
@SEGMENT”: “1”,
“IDDAT”: “011”,
“DATUM”: “20180917”,
“UZEIT”: “101221”
},
{
@SEGMENT”: “1”,
“IDDAT”: “028”,
“DATUM”: “20180917”
},
{
@SEGMENT”: “1”,
“IDDAT”: “017”,
“DATUM”: “20180918”
}
],
“E1EDK02”: {
@SEGMENT”: “1”,
“QUALF”: “029”,
“BELNR”: “2000000796”
},
“E1IDKU2”: {
@SEGMENT”: “1”,
“BUSFUN”: “001”,
“BUSGEO”: “DO”,
“BUSZFO”: “001”
},
“E1IDKU3”: {
@SEGMENT”: “1”,
“PAIRZAWE”: “T”,
“PAYRUNCC”: “0001”,
“PAYRUNID”: “COMM3”,
“PAYRUNDT”: “20180917”,
“RELNUM”: “000000050005”
},
“E1IDKU5”: {
@SEGMENT”: “1”,
“MOAQUAL”: “002”,
“MOABETR”: “9000.00”,
“CUXWAERZ”: “USD”
},
“E1IDB02”: [
{
@SEGMENT”: “1”,
“FIIQUALI”: “BA”,
“FIIBKENN”: “XXXXXXXXXXXXXXX”,
“FIIBKCDE”: “002”,
“FIIBKUKN”: “021000021”,
“FIIBKUCD”: “003”,
“FIIBKNAM”: “XXXXXXXXXXXXXXX”,
“FIIBKORT”: “TAMPA”,
“FIIBLAND”: “US”,
“FIIKONTO”: “XXXXXXXXXXXXXXX”,
“FIIKWAER”: “USD”
},
{
@SEGMENT”: “1”,
“FIIQUALI”: “BB”,
“FIIBKENN”: “XXXXXXXXXXXXXXXXX”,
“FIIBKCDE”: “003”,
“FIIBKNAM”: “XXXXXXXXXXXXXXXXXXx”,
“FIIBKORT”: “CHICAGO”,
“FIIBLAND”: “US”,
“FIIKONTO”: “XXXXXXXXXXXXXX”,
“FIIKNAME”: “XXXXXXXXXXXXXXXXXX”,
“FIIBKONT”: “01”
}
],
“E1EDKA1”: [
{
@SEGMENT”: “1”,
“PARVW”: “AG”,
“NAME1”: “XXXXXXXXXXXXXX”,
“STRAS”: “XXXXXXXXXXXXXXXX”,
“PFACH”: “2020”,
“ORT01”: “XXXXXXXXXXXXX”,
“PSTLZ”: “72762”,
“PSTL2”: “72765”,
“LAND1”: “US”,
“TELF1”: “(479)290-4000”,
“SPRAS”: “E”,
“ORT02”: “WASHINGTON”,
“REGIO”: “AR”,
“ISOAL”: “US”
},
{
@SEGMENT”: “1”,
“PARVW”: “BE”,
“PARTN”: “0000001018”,
“NAME1”: “XXXXXXXXXXXXXXXx”,
“NAME2”: “TEST NAME UPDATE”,
“NAME3”: “TEST TEST TEST”,
“NAME4”: “TEST”,
“STRAS”: “ONE APPLIED PLZ”,
“PFACH”: “XXXXXXXXXX”,
“ORT01”: “CLEVELAND”,
“PSTLZ”: “XXXXXXXXXXX”,
“PSTL2”: “XXXXXXXXX”,
“LAND1”: “US”,
“TELF1”: “XXXXXXXXXX”,
“TELFX”: “XXXXXXXXXXX”,
“ORT02”: “CUYAHOGA”,
“REGIO”: “OH”,
“ISOAL”: “US”,
“PFORT”: “PASADENA”,
“SPRAS_ISO”: “EN”
}
],
“E1IDPU1”: {
@SEGMENT”: “1”,
“DOCNAME”: “INV”,
“DOCNUMMR”: “5000005346”,
“DOCDATUM”: “20180917”,
“E1IDPU5”: [
{
@SEGMENT”: “1”,
“MOAQUAL”: “004”,
“MOABETR”: “9000.00”,
“CUXWAERZ”: “USD”
},
{
@SEGMENT”: “1”,
“MOAQUAL”: “003”,
“MOABETR”: “0.00”,
“CUXWAERZ”: “USD”
},
{
@SEGMENT”: “1”,
“MOAQUAL”: “005”,
“MOABETR”: “0.00”,
“CUXWAERZ”: “USD”
},
{
@SEGMENT”: “1”,
“MOAQUAL”: “006”,
“MOABETR”: “9000.00”,
“CUXWAERZ”: “USD”
}
],
“E1EDP03”: [
{
@SEGMENT”: “1”,
“IDDAT”: “016”,
“DATUM”: “20180917”
},
{
@SEGMENT”: “1”,
“IDDAT”: “015”,
“DATUM”: “20180917”
}
],
“E1EDP02”: [
{
@SEGMENT”: “1”,
“QUALF”: “009”,
“BELNR”: “5000005346”
},
{
@SEGMENT”: “1”,
“QUALF”: “010”,
“BELNR”: “5200000898”
}
]
},
“E1IDLU5”: [
{
@SEGMENT”: “1”,
“MOAQUAL”: “002”,
“MOABETR”: “9000.00”,
“CUXWAERZ”: “USD”
},
{
@SEGMENT”: “1”,
“MOAQUAL”: “003”,
“MOABETR”: “0.00”,
“CUXWAERZ”: “USD”
}
]
}
}
}

1 ACCEPTED SOLUTION

walkermic
New Contributor III

Close. I got it to work with $.entries()[0][0]

Thanks!

View solution in original post

5 REPLIES 5

tstack
Former Employee

I’m not quite clear on what you’re asking, so I’ll take a guess… Do you have a Router snap after the listener with branches for each child pipeline? The condition for the branches would need to check for the given property. One way to do that is with the hasOwnProperty() method, like so:

$.hasOwnProperty('PEXR2002')

You can then get the value in a Mapper with $PEXR2002 and pass the doc into the child pipeline.

walkermic
New Contributor III

I want to parse the value into it’s own field. At this point in the process I don’t want to do the evaluation now. I want a downstream process to do that. When I test this at http://jsonpath.com/?
the command $.*~ gives be back what I’m asking for. However, it does not in any of the snaplogic snaps.

I’m sorry, I’m still not understanding what you’re asking for. Can you attach an export of the pipeline you’re working on or provide some screenshots of the pipeline and the snap configurations.

Schevus
New Contributor III

If I’m reading this right, it sounds like the name of your root element of your json document stream can change, but you always want to grab the root element to be able to process later? If so, I think something like this could work?

image