A badly formed JSON string from a third party is sent to me. I tried using JSON.parse(str) to parse it in a JavaScript object, but of course it failed.
The reason is that keys are not strings:
{min: 100}
Unlike a valid JSON string (which is perfectly parsed):
{"min": 100}
I need to accept a string created due to an irregular shape. I think that forgetting to quote keys correctly is a common mistake. Is there a good way to change this to a valid JSON string so that I can parse it? At this point, I may have to disassemble the character by character and try to form an object that sounds awful.
Ideas?
lostintranslation
source share