Java POJO codec + any getter/any setter

Hi, is there any way to achieve Jackon like @JsonAnyGetter and @JsonAnySetter in a Bson POJOs?

I didn’t use this one, I had to write my own mapper… this looks promising;

https://mongojack.org/tutorial.html

HI @Maciej_Jedwabny,

This scenario isn’t currently supported with the PojoCodec. It might be achievable via a custom Convention but that would require some intense manipulation of the ClassModel and PropertyModel implementations.

It could be simpler to use a custom Codec / CodecProvider for this scenario.

Ross

Thanks for answers. I have managed this but it required copying literally whole org.bson.codecs.pojo.* package to add tiny modifications. Default pojo implementation is impossible to extend because of scopes and finals.

Hi,

Would you consider making a PR or filing a ticket and sharing the code as the basis for the start of the work? Its a good way to help extend the library and add new features.

Ross

1 Like

Sure, I will work on that, in the upcoming weekend hopefully.

1 Like