Parse ill formed JSON string
javascript, node.js
Solution
You could just eval, but that would be bad security practice if you don't trust the source. Better solution would be to either modify the string manually to quote the keys or use a tool someone else has written that does this for you (check out https://github.com/daepark/JSOL written by daepark).
Problem
I am being sent an ill formed JSON string from a third party. I tried using `JSON.parse(str)` to parse it into a JavaScript object but it of course failed. The reason being is that the keys are not strings: ``` {min: 100} ``` As opposed to valid JSON string (which parses just fine): ``` {"min": 100} ``` I need to accept the ill formed string for now. I imagine forgetting to properly quote keys is a common mistake. Is there a good way to change this to a valid JSON string so that I can parse it? For now I may have to parse character by character and try and form an object, which sounds awful. Ideas?