Following classes:
public class StructuralRule {
private List<Statement> statements;
.. /getter & setter
}
@JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class,
property = "id")
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "operator")
@JsonSubTypes({
@JsonSubTypes.Type(value = StatementEquals.class, name = "equals"),
@JsonSubTypes.Type(value = StatementIn.class, name = "in"),
@JsonSubTypes.Type(value = StatementLike.class, name = "like"),
})
public abstract class Statement<T> {
private String key;
private T value;
public Statement() {
}
public Statement(String key, T value) {
this.key = key;
this.value = value;
}
.. /getter & setter
}
When serializing a StructuralRule-Object the property "operator" inside
Statement is serialized too.
But when the List of Statements is serialized the "operator" disappears.
And when a single Statement is serialized then the "operator" is there.
new ObjectMapper().writeValueAsString(structuralRule)
*{"statements":[{"operator":"equals","id":1,"key":"keyx","value":"valy"}]}*
new ObjectMapper().writeValueAsString(structuralRule.getStatements()) //
missing "operator"*[{"id":1,"key":"keyx","value":"valy"}]*
new
ObjectMapper().writeValueAsString(structuralRule.getStatements().get(0))*{"operator":"equals","id":1,"key":"keyx","value":"valy"}*
I think it's bug.
What do you think?
--
You received this message because you are subscribed to the Google Groups
"jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/d/optout.