This throws: "Uncaught SyntaxError: Unexpected token n(…)" ...
var text = "notation: 'fixed', precision: 2";
JSON.parse("{" + text + "}");
No clue as to why or how to safely parse.
You should have tried a linter first.
The problem is that you are using single quote for key/value in your text or not using at all.
Your text should be:
var text = '"notation": "fixed", "precision": "2"';
2 doesn't necessarily need to be in quotes.You have wrong JSON, you should wrap keys to double quotes, like this
var text = "notation: 'fixed', precision: 2";
text = text.replace(/\'/g, '"').replace(/(\w+):/g, '"$1":');
console.log( JSON.parse("{" + text + "}") );
{ notation: 'fixed', precision: 2 }as a JavaScript object literal?