Hi, I use jackson-databind 2.8.3.
I want to serialize value with `@JsonTypeName`. When serialize with `List`,
the property value is not shown.
public class Main {
public static void main(String[] args) throws Exception {
ObjectMapper om = new ObjectMapper();
System.out.println(om.writeValueAsString(new ExampleContent()));
System.out.println(om.writeValueAsString(Arrays.asList(new
ExampleContent())));
}
@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.PROPERTY,
property = "type",
visible = true
)
@JsonSubTypes({
@JsonSubTypes.Type(ExampleContent.class)
})
abstract static public class AbstractContent {
}
@JsonTypeName("text")
public static class ExampleContent extends AbstractContent {
}
}
result
{"type":"text"}
[{}]
expected?
{"type":"text"}
[{"type":"text"}]
Do I need to add more settings or something?
Regards.
(I'm not sure, I send this a little time ago, but not posted. If send
multiple, sorry.)
--
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.