Skip to content

Commit

Permalink
Improved Json class
Browse files Browse the repository at this point in the history
  • Loading branch information
javadev authored Apr 13, 2024
1 parent 6a332d3 commit 0066e2f
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions src/main/java/com/github/underscore/Json.java
Original file line number Diff line number Diff line change
Expand Up @@ -372,19 +372,19 @@ private static void doWriteJson(Object value, JsonStringBuilder builder) {
}
}

public static String escape(String s) {
if (s == null) {
public static String escape(String inputString) {
if (inputString == null) {
return null;
}
StringBuilder sb = new StringBuilder();
escape(s, sb);
escape(inputString, sb);
return sb.toString();
}

private static void escape(String s, StringBuilder sb) {
final int len = s.length();
private static void escape(String inputString, StringBuilder sb) {
final int len = inputString.length();
for (int i = 0; i < len; i++) {
char ch = s.charAt(i);
char ch = inputString.charAt(i);
switch (ch) {
case '"':
sb.append("\\\"");
Expand Down Expand Up @@ -458,7 +458,7 @@ public static class JsonParser {
private int line;
private int lineOffset;
private int current;
private StringBuilder captureBuffer;
private StringBuilder captureBuffer = new StringBuilder();
private int captureStart;
private final int maxDepth;

Expand Down Expand Up @@ -761,9 +761,6 @@ private void read() {
}

private void startCapture() {
if (captureBuffer == null) {
captureBuffer = new StringBuilder();
}
captureStart = index - 1;
}

Expand Down

0 comments on commit 0066e2f

Please sign in to comment.