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

JsonObject as object field breaks Jackson object mapping #92

Open
nbartels opened this issue Apr 8, 2018 · 1 comment
Open

JsonObject as object field breaks Jackson object mapping #92

nbartels opened this issue Apr 8, 2018 · 1 comment

Comments

@nbartels
Copy link
Contributor

nbartels commented Apr 8, 2018

I have a object that contains a minimal-json JsonObject as field and I try to serialise the object with jackson to JSON to store the object as String and deserialise it afterwards. The mechanism is explained here:

http://www.baeldung.com/jackson-object-mapper-tutorial

As soon as I try to deserialise the stored object I run into this error message:

com.fasterxml.jackson.databind.exc.InvalidDefinitionException: 
Cannot construct instance of `com.restfb.json.JsonNumber` 
(no Creators, like default construct, exist): cannot deserialize from Object value 
(no delegate- or property-based Creator)

According to this message the default constructor is missing, but adding one seems not be a solution because JsonNumber, JsonString and JsonLiteral contain a inner private final field and it seems this disturbs the deserialisation process.

ATM the solution is to store the JSON as String and have a getter that parses the String with minimal-json on demand, but perhaps you are interested in solving this on your side ;)

@bernardosulzbach
Copy link
Contributor

I have a object that contains a minimal-json JsonObject as field (...)

I understand the issue you are describing. However, I've never considered having a class with a JsonObject member. Does it make sense in your domain? Is it a payload-like field in a message-like object?

Does Jackson make this possible to fix in the calling code? Such as by registering an object capable of transforming JsonObject into something that Jackson can understand and vice-versa.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants