diff --git a/HISTORY.md b/HISTORY.md index 220c52d..72f6d8a 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -3,6 +3,11 @@ https://github.com/josdejong/jsoneditor +## 2014-08-01, version 3.1.2 + +- Fixed `parseJS` not being able to parse a single quoted string to JSON. + + ## 2014-08-01, version 3.1.1 - Replaced parsing of JavaScript objects into JSON from `eval` to a dedicated diff --git a/src/js/util.js b/src/js/util.js index 9947874..fe54d44 100644 --- a/src/js/util.js +++ b/src/js/util.js @@ -68,7 +68,7 @@ define(function () { var jsonString = chars.join(''); // replace keys/values enclosed by single quotes with double quotes - jsonString = jsonString.replace(/(.)'/g, function ($0, $1) { + jsonString = jsonString.replace(/(.?)'/g, function ($0, $1) { var str = $1.replace(/"/g, '\\"'); // escape double quotes return ($1 == '\\') ? '\'' : str + '"'; });