Skip to content
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

Json: Support non immutable objects #54

Closed
jdmwood opened this issue Nov 21, 2014 · 3 comments
Closed

Json: Support non immutable objects #54

jdmwood opened this issue Nov 21, 2014 · 3 comments
Milestone

Comments

@jdmwood
Copy link

jdmwood commented Nov 21, 2014

It would be great if Immutables could serialise Json objects which are NOT themselves immutables. E.g.:

public class OldBean {
   public String getFoo() {...}
}

@Immutables.Value
public abstract class NewBean {
   public abstract OldBean getOldBean();
}

At the moment, the only way to handle this is to manually specify every old style of bean in the @Json.Import thing.

What would be great is if immutables just falls back to using a standard ObjectMapper to serialise/deserialise the objects which are not Immutables.

@elucash
Copy link
Member

elucash commented Nov 22, 2014

I guess it will be a good addition. I've made some experiments on this a some time ago. Back then I stopped when faced some unresolved recursions, but there should be a way out )

@jdmwood
Copy link
Author

jdmwood commented Nov 24, 2014

Awesome - thanks!

@elucash elucash added this to the 1.1 milestone Dec 1, 2014
elucash added a commit that referenced this issue Dec 19, 2014
delegates to Jackson
Marshaling.setFallbackCodec
@elucash
Copy link
Member

elucash commented Dec 21, 2014

Supported in 1.1.0(starting with rc1). The caveat is the current ObjectMapper may not be present in all contexts so sometimes you will need to provide some default coded via Marshaling.setFallbackCodec(). Thank!

@elucash elucash closed this as completed Dec 21, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants