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