in log4j-api/src/main/java/org/apache/logging/log4j/message/MapMessageJsonFormatter.java [79:160]
private static void format(final StringBuilder sb, final Object object, final int depth) {
if (depth >= MAX_DEPTH) {
throw new IllegalArgumentException("maxDepth has been exceeded");
}
// null
if (object == null) {
sb.append("null");
}
// map
else if (object instanceof IndexedStringMap) {
final IndexedStringMap map = (IndexedStringMap) object;
formatIndexedStringMap(sb, map, depth);
} else if (object instanceof Map) {
@SuppressWarnings("unchecked")
final Map<Object, Object> map = (Map<Object, Object>) object;
formatMap(sb, map, depth);
}
// list & collection
else if (object instanceof List) {
@SuppressWarnings("unchecked")
final List<Object> list = (List<Object>) object;
formatList(sb, list, depth);
} else if (object instanceof Collection) {
@SuppressWarnings("unchecked")
final Collection<Object> collection = (Collection<Object>) object;
formatCollection(sb, collection, depth);
}
// number & boolean
else if (object instanceof Number) {
final Number number = (Number) object;
formatNumber(sb, number);
} else if (object instanceof Boolean) {
final boolean booleanValue = (boolean) object;
formatBoolean(sb, booleanValue);
}
// formattable
else if (object instanceof StringBuilderFormattable) {
final StringBuilderFormattable formattable = (StringBuilderFormattable) object;
formatFormattable(sb, formattable);
}
// arrays
else if (object instanceof char[]) {
final char[] charValues = (char[]) object;
formatCharArray(sb, charValues);
} else if (object instanceof boolean[]) {
final boolean[] booleanValues = (boolean[]) object;
formatBooleanArray(sb, booleanValues);
} else if (object instanceof byte[]) {
final byte[] byteValues = (byte[]) object;
formatByteArray(sb, byteValues);
} else if (object instanceof short[]) {
final short[] shortValues = (short[]) object;
formatShortArray(sb, shortValues);
} else if (object instanceof int[]) {
final int[] intValues = (int[]) object;
formatIntArray(sb, intValues);
} else if (object instanceof long[]) {
final long[] longValues = (long[]) object;
formatLongArray(sb, longValues);
} else if (object instanceof float[]) {
final float[] floatValues = (float[]) object;
formatFloatArray(sb, floatValues);
} else if (object instanceof double[]) {
final double[] doubleValues = (double[]) object;
formatDoubleArray(sb, doubleValues);
} else if (object instanceof Object[]) {
final Object[] objectValues = (Object[]) object;
formatObjectArray(sb, objectValues, depth);
}
// string
else {
formatString(sb, object);
}
}