New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CollectionSerializer gets confused on how to handle elements #450
Comments
A deserialization converter works in this manner, so as a work-around, I am using a Serializer instead of a converter on the serialization side. ...
private static class InnerSerializer extends StdSerializer<Inner> {
protected InnerSerializer() {
super(Inner.class);
}
@Override
public void serialize(Inner value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonGenerationException {
jgen.writeStartArray();
Map map = new ObjectMapper().convertValue(value, Map.class);
for(int i = 0; i < map.size(); i++)
jgen.writeObject(map.get(String.valueOf(i)));
jgen.writeEndArray();
}
}
...
|
Quick update. In the case anyone comes across this, I solved my root problem in a much, much simpler way by using: @JsonFormat(shape=JsonFormat.Shape.ARRAY)
@JsonPropertyOrder({"stringProperty", "intProperty"}) I should have known there was a way to do this natively, I just didn't look hard enough. |
@roguefrequency ah yes. This is yet another feature that is not widely known, or extensively documented. I have blogged about it a bit, but it needs to catch on so there'll be more google hits :) |
The text was updated successfully, but these errors were encountered: