Skip to content

Commit

Permalink
Fixed idea warnings for class Json
Browse files Browse the repository at this point in the history
  • Loading branch information
javadev authored Mar 25, 2024
1 parent 2779fd2 commit ef96ef2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/main/java/com/github/underscore/Json.java
Original file line number Diff line number Diff line change
Expand Up @@ -407,18 +407,16 @@ private static void escape(String s, StringBuilder sb) {
case '\t':
sb.append("\\t");
break;
case '\u20AC':
sb.append('\u20AC');
case '':
sb.append('');
break;
default:
if (ch <= '\u001F'
|| ch >= '\u007F' && ch <= '\u009F'
|| ch >= '\u2000' && ch <= '\u20FF') {
String ss = Integer.toHexString(ch);
sb.append("\\u");
for (int k = 0; k < 4 - ss.length(); k++) {
sb.append("0");
}
sb.append("0".repeat(4 - ss.length()));
sb.append(ss.toUpperCase());
} else {
sb.append(ch);
Expand Down
3 changes: 3 additions & 0 deletions src/test/java/com/github/underscore/LodashTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1563,6 +1563,9 @@ void formatJson() {
assertEquals(
"{\n \"a\": {\n }\n}",
U.formatJson("{\n \"a\": {\n }\n}", Json.JsonStringBuilder.Step.FOUR_SPACES));
assertEquals(
"{\n \"a\": {\n }\n}",
U.formatJson("{\n \"a\": {\n }\n}", Json.JsonStringBuilder.Step.THREE_SPACES));
assertEquals(
"{\"a\":{}}",
U.formatJson("{\n \"a\": {\n }\n}", Json.JsonStringBuilder.Step.COMPACT));
Expand Down

0 comments on commit ef96ef2

Please sign in to comment.