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

Deserializer collections field with pre-existing values #1398

Closed
reinaldo-besen opened this issue Oct 5, 2016 · 2 comments
Closed

Deserializer collections field with pre-existing values #1398

reinaldo-besen opened this issue Oct 5, 2016 · 2 comments

Comments

@reinaldo-besen
Copy link

I suggest as an improvement, be able to perform the deserialization of a pre-existing object, considered the fields that are collections, where it was possible to define a key to the collection object, and it was still possible to pass a specific comparator for the type of collection, and with this key pattern was possible to recover the existing record in the collection and deserialize the existing record, instead of adding a new record in the collection, or have the ability to set an interceptor to carry out this work to find the record and return to be used by CollectionDeserializer.

At the moment I decided this scenario creating a specialization of ColletionDeserializer class, overwriting and replicating code, which in each Jackson version update will have to revise the code to keep compativilidade, and recording it as specific deserializer collections through the module confguration by setting one BeanDeserializerModifier.

module.setDeserializerModifier(new BeanDeserializerModifier()
        {           
          @Override
            public JsonDeserializer<?> modifyCollectionDeserializer(DeserializationConfig config,
                    CollectionType type, BeanDescription beanDesc, JsonDeserializer<?> deserializer) 
            {
                if(deserializer instanceof CollectionDeserializer)
                {
                    return new CustomCollectionDeserializer((CollectionDeserializer)deserializer);
                }
                else
                {
                    return deserializer;
                }
            }
        });

Thanks for your help.

@cowtowncoder
Copy link
Member

I plan to implement #1399 for 2.9, and I think that would cover this? (just created the issue -- have discussed the idea on jackson-dev list earlier).

@cowtowncoder
Copy link
Member

Assuming #1399 would cover this, closing.

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