Introduction
The native function to switch from json is much too limited. It fails if the input text differs slightly from the strict JSON format and the error message is not at all explicit.
JSONEx attempts to remedy this situation by correcting the input text.
JSONEx- add quotation marks around the keys if they do not have one.
- replace single quotes around keys or values with quotation marks
- remove the commas at the end of the list of properties
- Adds the missing right quotation mark to keys that have a left quotation mark
Error handling is improved. Instead of indicating a character position in the input string more or less at the parser's misunderstanding, JSONEx indicates the type of expected word, an extract from the input string where it is located. error.
How it worksAt first, JSONEx uses the native function of the JSON API. If it fails, the input string is corrected and JSONEx retries the call to the native function a second time. If the parsing fails you get the improved message from the first parsing attempt and the improved message from the 2nd attempt.