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
Improve error message when @JsonValue and @JsonProperty are applied to the same class #498
Comments
The problem isn't with With What error message tries to tell, then, is that it does not know how to map a JSON Array: what is missing is perhaps indication that a JSON Object would work (although in general other types might be acceptable, depending on details). As always, I am open to suggestions on how to improve error messaging: current message is not as informative as it could be. |
How about this? com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of com.vtlr.backend.entity.AuthenticationsEntities$GetAuthentications. @JsonProperty implies the incoming stream is an object, but the stream contained an array instead. |
Something along those lines would be an improvement, if anyone can point out where to determine this. The main challenge is that the place where error is reported may not have all pertinent information to determine more accurate cause. |
Do you have enough information at the point you are currently throwing the JsonMappingException? You should have parsed all the annotations by this point. |
@cowwoc All the information has long since been processed from annotations, yes, but not all of that information is passed along the calls, so the point where low-level problem is encountered typically lacks enough context to make educated guesses. Having said that it is possible that enough information is accessible to give more accurate suggestion for problem. Just mentioning that it's hard to know before looking at location. |
Not sure what if anything could be done here; may be reopened with suggestions (although probably better to file a new issue to keep it closer to head). |
Jackson 2.4.1 (data-bind 2.4.1.1)
I attempted to deserialize
["http://example.com/"]
using:This resulted in Jackson throwing:
Once I removed
@JsonProperty("authentications")
everything worked fine. It took me a couple of hours to figure out what was wrong because the error makes it seem as if the input stream is empty when in fact there was nothing wrong with it.Is it possible to improve the error message so Jackson says something along the lines of: "@JsonValue and @JsonProperty annotations cannot be applied to the same class. You must remove one of these annotations."?
The text was updated successfully, but these errors were encountered: