@@ -347,8 +347,6 @@ private static String formatObject(Object object) {
347
347
return iFormatter .format (object );
348
348
}
349
349
}
350
- if (object instanceof String || object instanceof JSONObject || object instanceof JSONArray )
351
- return object .toString ();
352
350
if (object .getClass ().isArray ()) return LogFormatter .array2String (object );
353
351
if (object instanceof Throwable ) return LogFormatter .throwable2String ((Throwable ) object );
354
352
if (object instanceof Bundle ) return LogFormatter .bundle2String ((Bundle ) object );
@@ -1009,6 +1007,10 @@ static String collection2String(Collection collection) {
1009
1007
}
1010
1008
1011
1009
static String object2String (Object object ) {
1010
+ if (object instanceof String || object instanceof JSONObject ||
1011
+ object instanceof JSONArray ) {
1012
+ return object .toString ();
1013
+ }
1012
1014
Class <?> clazz = object .getClass ();
1013
1015
List <Field > tmp = Arrays .asList (clazz .getDeclaredFields ());
1014
1016
ArrayList <Field > list = new ArrayList <>(tmp );
@@ -1028,13 +1030,14 @@ static String object2String(Object object) {
1028
1030
Field [] a = new Field [list .size ()];
1029
1031
Field [] fields = list .toArray (a );
1030
1032
JSONObject jsonObject = new JSONObject ();
1031
- for (Field field : fields ) {
1032
- String fieldName = field .getName ();
1033
- try {
1033
+ try {
1034
+ jsonObject .put ("object" , object .toString ());
1035
+ for (Field field : fields ) {
1036
+ String fieldName = field .getName ();
1034
1037
Object obj = field .get (object );
1035
1038
jsonObject .put (fieldName , obj );
1036
- } catch (Exception ignore ) {
1037
1039
}
1040
+ } catch (Exception ignore ) {
1038
1041
}
1039
1042
return jsonObject .toString ();
1040
1043
}
0 commit comments