Split JSON formatter lines (see if this helps with browser issues)

This commit is contained in:
Mike Primm 2020-09-20 17:56:20 -05:00
parent 0daa0b8b33
commit 5407f3c026
1 changed files with 7 additions and 5 deletions

View File

@ -66,8 +66,10 @@ public class Json {
s.append("\"");
escape((String)o, s);
s.append("\"");
} else if (o instanceof Integer || o instanceof Long || o instanceof Float || o instanceof Double) {
} else if (o instanceof Integer || o instanceof Long) {
s.append(o.toString());
} else if (o instanceof Float || o instanceof Double) {
s.append(String.format("%.2f",((Number)o).doubleValue()));
} else if (o instanceof Map<?, ?>) {
Map<?, ?> m = (Map<?, ?>) o;
s.append("{");
@ -82,7 +84,7 @@ public class Json {
s.append(": ");
appendJson(entry.getValue(), s);
}
s.append("}");
s.append("}\n");
} else if (o instanceof List<?>) {
List<?> l = (List<?>) o;
s.append("[");
@ -91,7 +93,7 @@ public class Json {
if (count++ > 0) s.append(",");
appendJson(l.get(i), s);
}
s.append("]");
s.append("]\n");
} else if (o.getClass().isArray()) {
int length = Array.getLength(o);
s.append("[");
@ -100,7 +102,7 @@ public class Json {
if (count++ > 0) s.append(",");
appendJson(Array.get(o, i), s);
}
s.append("]");
s.append("]\n");
} else if (o instanceof Object) /* TODO: Always true, maybe interface? */ {
s.append("{");
boolean first = true;
@ -127,7 +129,7 @@ public class Json {
s.append(": ");
appendJson(fieldValue, s);
}
s.append("}");
s.append("}\n");
} else {
s.append("undefined");
}