Fixed `parseJS` not being able to parse a single quoted string to JSON

This commit is contained in:
jos 2014-08-01 09:06:54 +02:00
parent 2662d04b4d
commit fada177c4a
2 changed files with 6 additions and 1 deletions

View File

@ -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

View File

@ -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 + '"';
});