We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I have a versioned model class which has a field that i would like to use a custom serializer on:
@JsonVersionedModel(currentVersion = "1", toCurrentConverterClass = ToCurrentLoanPolicyOverrideConverter.class) public class LoanPolicyOverride extends LaserData { @JsonSerialize(using = PolicyIdSerializer.class) private Policy policy; }
But when I do the modelVersion attribute is lost in the serialized json.
Here the serializer should only outut the id of the Policy object, i have tried two approaches for the serializer:
public void serialize( Policy value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException { jgen.writeStartObject(); jgen.writeStringField("id", value.getId()); jgen.writeEndObject(); }
public void serialize( Policy value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException { if (value == null) { jgen.writeNull(); } else { Policy simple = Policy.builder(value.getClassification().getClassificationCode().getCode()).id(value.getId()).build(); BeanSerializerFactory.instance.createSerializer(provider, SimpleType.construct(Policy.class)).serialize(simple, jgen, provider); } }
Any ideas on how to use a custom serializer AND keep the model version?
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I have a versioned model class which has a field that i would like to use a custom serializer on:
But when I do the modelVersion attribute is lost in the serialized json.
Here the serializer should only outut the id of the Policy object, i have tried two approaches for the serializer:
Any ideas on how to use a custom serializer AND keep the model version?
The text was updated successfully, but these errors were encountered: