If I fetch a supposed JSON string the JSON parser will throw an error if it's not a correct JSON format.
Could it be possible to have an option to return a error string instead or should I do a JSON validation myself before throwing an JSON to the parser?
Best practice parsing JSON?
Moderators: JRL, Dorian (MJT support)
- Grovkillen
- Automation Wizard
- Posts: 1132
- Joined: Fri Aug 10, 2012 2:38 pm
- Location: Bräcke, Sweden
- Contact:
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Re: Best practice parsing JSON?
Use IGNOREERRORS and/or ONERROR and look at the LAST_ERROR variable to see what the error is, if any.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
- Grovkillen
- Automation Wizard
- Posts: 1132
- Joined: Fri Aug 10, 2012 2:38 pm
- Location: Bräcke, Sweden
- Contact:
Re: Best practice parsing JSON?
Thanks Marcus! Worked like a charm! 
If someone else is wondering:

If someone else is wondering:
Code: Select all
Let>ONERROR=CHECK_ERROR
Let>TEST_URL=https://jsonplaceholder.typicode.com/users
HTTPRequest>TEST_URL,,GET,,TEST_JSON,,,,
JSONParse>TEST_JSON,$[*]['id'],TEST_ID
MDL>TEST_ID_1
Let>TEST_URL=error
HTTPRequest>TEST_URL,,GET,,TEST_JSON,,,,
JSONParse>TEST_JSON,$[*]['id'],TEST_ID
MDL>TEST_ID_1
SRT>CHECK_ERROR
//MDL>LAST_ERROR
Let>TEST_ID_1=LAST_ERROR
END>CHECK_ERROR