Fix up some null values, and add map translation to Json in JsonObject.java

This commit is contained in:
Aria 2023-06-16 01:56:31 -07:00
parent d764e6c7b4
commit a28edce3e5
3 changed files with 16 additions and 7 deletions

View file

@ -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){
}
}

View file

@ -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 ( );

View file

@ -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();
}