Skip to content

Commit 54a0de5

Browse files
committed
Preserve spaces in plain strings
Treat double-quote characters at the beginning of the received JSON as the beginning of a string. Previously, a double-quote character at position 0 of the received JSON was disregarded (causing any spaces in the JSON string to be removed).
1 parent 4dce67f commit 54a0de5

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

extension/src/json-viewer/jsl-format.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@ jsl.format = (function () {
7373
}
7474
break;
7575
case '"':
76-
if (i > 0 && (json.charAt(i - 1) !== '\\' || (json.charAt(i - 1) == '\\' && json.charAt(i - 2) == '\\'))) {
76+
if (i === 0) {
77+
inString = true;
78+
}
79+
else if (json.charAt(i - 1) !== '\\' || (json.charAt(i - 1) == '\\' && json.charAt(i - 2) == '\\')) {
7780
inString = !inString;
7881
}
7982
newJson += currentChar;

0 commit comments

Comments
 (0)