Hello,
I have got an interface:
@Nonnull
String name();
@Nonnull
Object generate();
void registerAndExecute( @Nonnull final String p_tasklist );
and then multiple classes which implements this interface, but the classes does not contains any properties.
No I would like to serialize the classname with GSON, so I have creates my own serializer & deserializer, my deserializer is working, but my serializer not:
final class CSerializeActivityFactory implements JsonSerializer<IActivityFactory>
{
@Override
public JsonElement serialize( final IActivityFactory p_element, final Type p_type, final JsonSerializationContext p_ctx )
{
return p_ctx.serialize( p_element.getClass().getName() );
}
}
I have registered the serializer on my GSON with gsonbuilder.registerTypeAdapter( IActivityFactory.class, new CSerializerActivityFactory() )
In my case I would like to pass the class name and create on the deserializing process a new class instance (this is working), but my object which I passed into gson for serialization is skipped / empty, so the deserializer breaks.
I have tried also a registerHierarchyType and I'm trying a TypeAdapterFactory.
In tries my serializing method is not executed. Can anybody give me a helpful tip?
Thanks a lot
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 294 |
Nodes: | 16 (2 / 14) |
Uptime: | 245:13:07 |
Calls: | 6,626 |
Calls today: | 2 |
Files: | 12,175 |
Messages: | 5,320,562 |