Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Anuken/Arc
Browse files Browse the repository at this point in the history
  • Loading branch information
Anuken committed Jul 5, 2024
2 parents 49d5ce4 + d4867f6 commit b857594
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion arc-core/src/arc/util/serialization/Json.java
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,6 @@ public void writeValue(Object value, Class knownType, Class elementType){
writeObjectEnd();
return;
}

if(value instanceof ObjectIntMap){
if(knownType == null) knownType = ObjectIntMap.class;
writeObjectStart(actualType, knownType);
Expand All @@ -614,6 +613,16 @@ public void writeValue(Object value, Class knownType, Class elementType){
writeObjectEnd();
return;
}
if(value instanceof ObjectFloatMap){
if(knownType == null) knownType = ObjectFloatMap.class;
writeObjectStart(actualType, knownType);
for(ObjectFloatMap.Entry entry : ((ObjectFloatMap<?>)value).entries()){
writer.name(convertToString(entry.key));
writer.value(entry.value);
}
writeObjectEnd();
return;
}
if(value instanceof IntMap){
if(knownType == null) knownType = IntMap.class;
writeObjectStart(actualType, knownType);
Expand Down Expand Up @@ -1062,6 +1071,14 @@ public <T> T readValue(Class<T> type, Class elementType, JsonValue jsonData, Cla

return (T)result;
}
if(object instanceof ObjectFloatMap){
ObjectFloatMap result = (ObjectFloatMap)object;
for(JsonValue child = jsonData.child; child != null; child = child.next){
result.put(elementType != null ? readValue(elementType, null, new JsonValue(child.name)) : child.name, child.asFloat());
}

return (T)result;
}
if(object instanceof IntMap){
IntMap result = (IntMap)object;
for(JsonValue child = jsonData.child; child != null; child = child.next){
Expand Down

0 comments on commit b857594

Please sign in to comment.