diff --git a/src/main/java/org/dynmap/web/Json.java b/src/main/java/org/dynmap/web/Json.java index 17c1d54f..ea0a7f84 100644 --- a/src/main/java/org/dynmap/web/Json.java +++ b/src/main/java/org/dynmap/web/Json.java @@ -15,13 +15,59 @@ public class Json { return sb.toString(); } + public static void escape(String s, StringBuilder s2) { + for(int i=0;i='\u0000' && ch<='\u001F') || (ch>='\u007F')){ + String ss=Integer.toHexString(ch); + s2.append("\\u"); + for(int k=0;k<4-ss.length();k++){ + s2.append('0'); + } + s2.append(ss.toUpperCase()); + } + else{ + s2.append(ch); + } + } + }//for + } + public static void appendJson(Object o, StringBuilder s) { if (o == null) { s.append("null"); } else if (o instanceof Boolean) { s.append(((Boolean) o) ? "true" : "false"); } else if (o instanceof String) { - s.append("\"" + JSONObject.escape((String)o) + "\""); + s.append("\""); + escape((String)o, s); + s.append("\""); } else if (o instanceof Integer || o instanceof Long || o instanceof Float || o instanceof Double) { s.append(o.toString()); } else if (o instanceof Map) {