Fixed `parseJS` not being able to parse a single quoted string to JSON
This commit is contained in:
parent
2662d04b4d
commit
fada177c4a
|
@ -3,6 +3,11 @@
|
||||||
https://github.com/josdejong/jsoneditor
|
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
|
## 2014-08-01, version 3.1.1
|
||||||
|
|
||||||
- Replaced parsing of JavaScript objects into JSON from `eval` to a dedicated
|
- Replaced parsing of JavaScript objects into JSON from `eval` to a dedicated
|
||||||
|
|
|
@ -68,7 +68,7 @@ define(function () {
|
||||||
var jsonString = chars.join('');
|
var jsonString = chars.join('');
|
||||||
|
|
||||||
// replace keys/values enclosed by single quotes with double quotes
|
// 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
|
var str = $1.replace(/"/g, '\\"'); // escape double quotes
|
||||||
return ($1 == '\\') ? '\'' : str + '"';
|
return ($1 == '\\') ? '\'' : str + '"';
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue