diff --git a/src/main/java/com/github/underscore/Json.java b/src/main/java/com/github/underscore/Json.java index dbbc881c..d1add346 100644 --- a/src/main/java/com/github/underscore/Json.java +++ b/src/main/java/com/github/underscore/Json.java @@ -407,8 +407,8 @@ 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' @@ -416,9 +416,7 @@ private static void escape(String s, StringBuilder sb) { || 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); diff --git a/src/test/java/com/github/underscore/LodashTest.java b/src/test/java/com/github/underscore/LodashTest.java index 76f2a35f..33759601 100644 --- a/src/test/java/com/github/underscore/LodashTest.java +++ b/src/test/java/com/github/underscore/LodashTest.java @@ -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));