Some more fixes in `parseJS`
This commit is contained in:
parent
fada177c4a
commit
8ca4c75326
|
@ -5,7 +5,8 @@ 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.
|
||||
- Some fixes/improvements in `parseJS` (to parse a JSON object from a JavaScript
|
||||
object).
|
||||
|
||||
|
||||
## 2014-08-01, version 3.1.1
|
||||
|
|
|
@ -45,7 +45,9 @@ define(function () {
|
|||
while(i < jsString.length) {
|
||||
var c = jsString.charAt(i);
|
||||
|
||||
if (c === '"' || c === '\'') {
|
||||
var isEscaped = jsString.charAt(i - 1) === '\\';
|
||||
if ((c === '"' || c === '\'') && !isEscaped) {
|
||||
|
||||
if (c === inString) {
|
||||
// end of string
|
||||
inString = false;
|
||||
|
@ -55,10 +57,8 @@ define(function () {
|
|||
inString = c;
|
||||
}
|
||||
else {
|
||||
// add escape character if not escaped
|
||||
if (jsString.charAt(i - 1) !== '\\') {
|
||||
chars.push('\\');
|
||||
}
|
||||
// add escape character
|
||||
chars.push('\\');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue