Skip to content

Commit 0066e2f

Browse files
authored
Improved Json class
1 parent 6a332d3 commit 0066e2f

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

src/main/java/com/github/underscore/Json.java

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -372,19 +372,19 @@ private static void doWriteJson(Object value, JsonStringBuilder builder) {
372372
}
373373
}
374374

375-
public static String escape(String s) {
376-
if (s == null) {
375+
public static String escape(String inputString) {
376+
if (inputString == null) {
377377
return null;
378378
}
379379
StringBuilder sb = new StringBuilder();
380-
escape(s, sb);
380+
escape(inputString, sb);
381381
return sb.toString();
382382
}
383383

384-
private static void escape(String s, StringBuilder sb) {
385-
final int len = s.length();
384+
private static void escape(String inputString, StringBuilder sb) {
385+
final int len = inputString.length();
386386
for (int i = 0; i < len; i++) {
387-
char ch = s.charAt(i);
387+
char ch = inputString.charAt(i);
388388
switch (ch) {
389389
case '"':
390390
sb.append("\\\"");
@@ -458,7 +458,7 @@ public static class JsonParser {
458458
private int line;
459459
private int lineOffset;
460460
private int current;
461-
private StringBuilder captureBuffer;
461+
private StringBuilder captureBuffer = new StringBuilder();
462462
private int captureStart;
463463
private final int maxDepth;
464464

@@ -761,9 +761,6 @@ private void read() {
761761
}
762762

763763
private void startCapture() {
764-
if (captureBuffer == null) {
765-
captureBuffer = new StringBuilder();
766-
}
767764
captureStart = index - 1;
768765
}
769766

0 commit comments

Comments
 (0)