-
Notifications
You must be signed in to change notification settings - Fork 47
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
JsonMappingException when field is not present #8
Comments
I'd like to contribute a fix, but I'm not sure what Basepom is -- googling for it doesn't help. |
That's odd, this branch should handle that case. Can you provide the full JSON string being deserialized as well as the protobuf definitions? Also which version of the library are you using? Basepom is just the parent pom that the project uses, it provides a bunch of preconfigured maven plugins to reduce boilerplate. It's still just a normal maven project that can be compiled with |
Figured it out! I made a small test case: https://gist.github.com/skizzybiz/7fe2537641bb157b868a The problem is when I have only the main constructor designated as |
The gist references |
Whoops, updated. It's just an empty object. |
Hmm, to me it looks like a bug in Jackson. An empty object like that should be represented by a |
Fixed and added some tests for |
@cowtowncoder is the observed behavior with |
@HiJon89 Yes, unfortunately it is. This is one of not-well-documented parts: an Object deserializer may get START_OBJECT, or the token immediately after that. This is why I forget why such handling was included in the first place; my guess is that there is a case where allowing this will remove the need for buffering for sake of only including virtual |
Did this get fixed in jackson 2.5? I am unable to parse something with 'field:{}' in it |
@a86c6f7964 are you referring to an issue with jackson-datatype-protobuf or just a general Jackson problem when writing your own deserializer? |
When using 0.7.0 of jackson-datatype-protobuf, and jackson version 2.5 a json that looks like |
Ah I see the issue, I just fixed it in bf378ab I'm releasing as 0.9.2 now |
It looks like the library isn't designed to handle null values for a protobuf-based field. See this exception:
In this example, the source JSON doesn't include the
"address"
field (which is based onCameraPathFrame
) intentionally, as it's meant to be optional.The text was updated successfully, but these errors were encountered: