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,12 +57,10 @@ define(function () {
|
|||
inString = c;
|
||||
}
|
||||
else {
|
||||
// add escape character if not escaped
|
||||
if (jsString.charAt(i - 1) !== '\\') {
|
||||
// add escape character
|
||||
chars.push('\\');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
chars.push(c);
|
||||
i++;
|
||||
|
|
Loading…
Reference in New Issue