-
-
Notifications
You must be signed in to change notification settings - Fork 797
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 Pointer inconsistent when serializing first element of an array #1154
Comments
While description suggest there is a problem, what is really needed is a reproduction as code (unit test). |
I also have the issue with serialize. It does not depend on polymorphic types. The simpliest I can come with is the following. It does not make any sense since the custom serializer juste calls a default one but its for unit testing purpose. The custom serializer
The unit test class
Parent class
Child class
The result: I understand why I get there, it is not considering the array has started until the first element was written. But inside |
Ok thanks. Reading through it all, I am not actually sure this is bug: For writing I can see how it could be either current (just written) -- like currently -- or "next to write". And changing this behavior would probably be breaking change for existing usage as well... assuming writer-side location is commonly used (I'd guess custom serializers do use it). So. Not sure what to do here. I may have to consider this "working as-is". |
I understand your explanation but it is still odd to be in a serialize method, receive an array element value as parameter and then get a JsonPointer that refers to the array itself. |
@itineric Yeah usage of One thing that might be helpful in figuring out things is to use Having said all that; if there was a patch to add an alternate |
During serialization, when using a custom serializer, the JsonPointer is inconsistent when serializing the first element. Instead of having
/myList/0
we get/myList
This happens because we enter this part of code : https://github.com/FasterXML/jackson-core/blob/2.17/src/main/java/com/fasterxml/jackson/core/JsonPointer.java#L212
The call stack looks like this, the Object received in my
CustomSerializer.serialize
method is the first element of my array.Additional info: the problem seems to be the _index of _writeContext of JsonGenerator instance which is -1 but should be 0 at that time.
The text was updated successfully, but these errors were encountered: