Closed mguldner closed 5 years ago
Hi :wave:
Yeah, the default serializer can only cope with no-arg constructors, so you need to provide a component-specific serializer. The serializer backends - json, json-libgdx and kryo - each provide a register(class, serializer)
method for this purpose. so for the libgdx JsonArtemisSerializer
, something like:
serializer.register(Position.class, new Json.Serializer<Position>() {
@Override
public void write(Json json, Position object, Class knownType) {
}
@Override
public Position read(Json json, JsonValue jsonData, Class type) {
return null;
}
});
Ok ! Thanks for your answer, I'll try to make it work! :)
Nice, closing this for now then :)
I implemented what you proposed for a generic object of type EnumMap<T, U> (T and U being serializable objects according to artemis-odb). Could it be useful to create a MR whit that ?
Could it be useful to create a MR whit that ?
Cool! Please do :)
Hello,
I'm working on a project using artemis-odb. I started to work on the serialization part but I've got this error :
This error is caused by :
I receive this error when I try to serialize a Component with an instance variable of type EnumMap. It seems that, because no constructor exists for EnumMap with no arguments, the serialization process can't work because using Reflection.
Is there a way to make it work ?
PS : I found this related issue in Kryo project : https://github.com/EsotericSoftware/kryo/issues/488