I have a string column that has JSON payloads in it. This is the way our partner stores messages from automated machines. The trouble is that their database sometimes gets non-JSON messages so my :payload column has rows that cannot be parsed to JSON simply.
I wrapped my parse function with a Try block but even then I'm getting an alert for each row that includes non-JSON-compliant string. It even crashes JMP14 fully sometimes. I could ignore errors but that's not a great way of writing robust code.
Local(
{ parsed = [=> ""] },
Try( parsed = Parse JSON( :payload ) );
parsed;
);
This fails so badly. In rows where :payload is empty instead of having a JSON string, it returns a "." for some reason. I have no idea where the dot comes from.
Is there a way to use JSON parsing functions in a failsafe manner? Any help is appreciated.
Note:
Here's some examples of the kinds of JSON that I'm dealing with and they get parsed properly:
{"assetId":"AthensPaintLineMotor4",
"dataItemId":"Temperature1",
"dateTime":"2018-02-22T19:44:41",
"value":"91.51"}
{"assetId":"OKUMA-Genos-2","dateTime":"2018-04-30T11:59:13","dataItemId":"Lp1block","dataItemName":"p1block","value":"UNAVAILABLE"}
{"assetId":"OKUMA-Genos-2","dateTime":"2018-04-30T11:59:13","dataItemId":"Lp1MacManPanelHistory","dataItemName":"p1MacManPanelHistory","value":"2018/04/30 07:58:12 @Change Window:[26026]"}
What we see of the real world is not the unvarnished real world but a model of the real world, constructed so it is useful for dealing with the real world. —Richard Dawkins