mardi 21 avril 2015

Jersey2 with Spring3: Abstract class JSON serialization and missing properties

Vote count: 0

I'm using Jersey-spring3 v2.17

All is working fine. Objects serialized from REST services are correctly exposed with JSON format.

Only objects from abstract classes are not correctly serialized. Only the type of the concrete class is present and correctly defined in the JSON object.

Some information regarding my configuration: Jersey / Jackson configuration in the Application configuration class:

register(JacksonFeature.class);

The abstract class:

    @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type")  
    @JsonSubTypes({  
            @Type(value = Dog.class, name = "dog"), 
            @Type(value = Cat.class, name = "cat"), 
            @Type(value = Horse.class, name = "horse") })
    public abstract class Animal {
private String name;
private String description
    ...

Output is currently on this format (no object property are present)

[{"type":"dog"},{"type":"cat"},{"type":"horse"}]

Any idea to fix my issue regarding missing properties in my JSON output ?

asked 29 secs ago
fvisticot
1,438



Jersey2 with Spring3: Abstract class JSON serialization and missing properties

Aucun commentaire:

Enregistrer un commentaire