You could sanitize the JSON using a regular expression replace:
var badJson = "{muh: 2}";
var correctJson = badJson.replace(/(['"])?([a-z0-9A-Z_]+)(['"])?:/g, '"$2": ');
JSON.parse(correctJson);
More Related Contents:
- How to change data php to javascript json [closed]
- how to parse json array
- jQuery AJAX cross domain
- I keep getting “Uncaught SyntaxError: Unexpected token o”
- How to get JSON from URL in JavaScript?
- JSON find in JavaScript
- How to compare arrays in JavaScript?
- Ajax request returns 200 OK, but an error event is fired instead of success
- Difference between JSON.stringify and JSON.parse
- Add new attribute (element) to JSON object using JavaScript
- JavaScript loop through JSON array?
- Chrome refuses to execute an AJAX script due to wrong MIME type
- D3 force layout – linking nodes by name instead of index
- fetch() unexpected end of input
- Object copy using Spread operator actually shallow or deep?
- Loop through JSON object List
- Encoding Javascript Object to Json string
- Iterating through/Parsing JSON Object via JavaScript
- Convert string array to array in javascript
- sort json object in javascript
- jQuery AJAX Call to PHP Script with JSON Return
- console.log(result) prints [object Object]. How do I get result.name? [duplicate]
- Compare 2 JSON objects [duplicate]
- Trying to load local JSON file to show data in a html page using JQuery
- Count console.log objects
- JavaScript/JSON: Get unknown property of an object
- how to convert xml to json using jquery
- Cross-Origin resource sharing and file://
- sending data as JSON object from Python to Javascript with Jinja [duplicate]
- Push JSON Objects to array in localStorage