jsonGet() Need Correct Path Syntax

I've tried to follow all the examples in this forum to get the function to return the 'cameraId' value from the following json:

{"dispositions":[{"scannedLabel":"m073770000100000000006700","cameraId":"2023031020313301672","inductNumber":0,"intendedLane":"123","actualLane":"123","labelStatus":"NORMAL","tiltTrayId":"TiltTray"}]}

The following Expression:

jsonGet({[MQTT Engine]IBM_MQTT/MHE/SORTER/DISPOSITION},'dispositions')

returns the following:

[{"scannedLabel":"m073770000100000000006700","cameraId":"2023031020313301672","inductNumber":0,"intendedLane":"123","actualLane":"123","labelStatus":"NORMAL","tiltTrayId":"TiltTray"}]

the following results in an expression error:

jsonGet({[MQTT Engine]IBM_MQTT/MHE/SORTER/DISPOSITION},'dispositions.cameraId')

It looks to me as though the jsonGet() function doesn't support nested paths. How did you get it to work at all?

I found a work around. I have a Document Expression Tag: 'dispositions' that has the following expression:

The 'dispositions' tag is referenced as the 'Source Tag Path' in a derived tag, 'dispositionTrigger' with the following Read Expression:

I don't think that's working because the JSON in the first parameter is working because it's being evaluated as a tag path. The nested path error is because of that. Try wrapping your test JSON in single quotes.

@hwbrill - you just need an array index in your JSON get expression? dispositions[0].cameraId.

2 Likes

that works too! Thank you @PGriffith