Skip to content

Instantly share code, notes, and snippets.

View kirant400's full-sized avatar
🎯
Focusing

Kirant400 kirant400

🎯
Focusing
View GitHub Profile
@larruda
larruda / unquoted_json_fix.js
Last active November 22, 2022 09:49
REGEX to add quotes to JSON unquoted keys (turns an invalid JSON into a valid one).
json_string.replace(/(\s*?{\s*?|\s*?,\s*?)(['"])?([a-zA-Z0-9]+)(['"])?:/g, '$1"$3":');
eval('var json = new Object(' + json_string + ')');