Fix up some null values, and add map translation to Json in JsonObject.java
This commit is contained in:
parent
d764e6c7b4
commit
a28edce3e5
3 changed files with 16 additions and 7 deletions
|
@ -34,12 +34,17 @@ public class DynamicDeserializer
|
|||
field.setAccessible ( true );
|
||||
|
||||
|
||||
if( !( field.getType ().isAnnotationPresent ( DynSerial.class ) ))
|
||||
{
|
||||
field.set ( object, map.get ( field.getName () ) );
|
||||
}else {
|
||||
Object tmp = deserialize ( (Map<String, Object> ) map.get ( field.getName () ), field.getType ());
|
||||
field.set ( object, tmp );
|
||||
try{
|
||||
|
||||
if( !( field.getType ().isAnnotationPresent ( DynSerial.class ) ))
|
||||
{
|
||||
field.set ( object, map.get ( field.getName () ) );
|
||||
}else {
|
||||
Object tmp = deserialize ( (Map<String, Object> ) map.get ( field.getName () ), field.getType ());
|
||||
field.set ( object, tmp );
|
||||
}
|
||||
}catch(Exception e){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@ public class DynamicSerializer {
|
|||
if ( field.isAnnotationPresent ( IgnoreSerialization.class ) )
|
||||
continue;
|
||||
Object fieldVal = field.get ( inst );
|
||||
if(fieldVal == null)continue;
|
||||
|
||||
String fieldName = field.getName ( );
|
||||
|
||||
|
|
|
@ -89,7 +89,10 @@ public class JsonObject {
|
|||
} else if (value instanceof JsonObject js) {
|
||||
return js.toJSONString();
|
||||
} else if (value instanceof List) {
|
||||
return toJSONList((List<Object>) value);
|
||||
return toJSONList ( ( List<Object> ) value );
|
||||
} else if(value instanceof Map<?,?> mp )
|
||||
{
|
||||
return new JsonObject ( (Map<String, Object> ) mp ).toJSONString ();
|
||||
} else {
|
||||
return value.toString();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue