Hi,
We are using @JsonMerge in our data model and this feature is very
appealing in one of our use case where we have a JSON template
configuration file we'd like to merge with some other values received from
a REST API. It works fine for our POJOs but it looks merging collection
regardless of their @JsonIdentityInfo. If confirmed, that could be a nice
enhancement to evaluate e.g. not to duplicate the items in a collection but
check for their identity first, then merge accordingly (also possibly
driven by configuration).
Anyway, we are searching for workaround suggestions like using custom
deserializer. Any suggestion? Because in such case, how would it be
possible to reuse the "merge facility" on the objects? Any example or hint?
Please find below a basic illustration if necessary (note: our items can
also be subclasses but that's not the point here). For example, consider
the following:
public class Container {
@JsonMerge
private List<Item> items;
// ...
}
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class,
property
= "name")
public class Item {
private String name;
private String value;
//...
}
Our JSON template looks like:
{ "items": [{"name":"item1", "value": "value1"}, {"name":"item2", "value":
"value2"}] }
And we need it would be merged with:
{ "items": [{"name":"item2", "value": "value2update"}, {name:"item3",
"value": "value3"}] }
After using ObjectMapper.readerForUpdating(...), we'd like to obtain:
{ "items": [{"name":"item1", "value": "value1"}, {"name":"item2", "value":
"value2update"}, {name:"item3", "value": "value3"}] }
As of today, unless we made a mistake, we are getting:
{ "items": [{"name":"item1", "value": "value1"}, {"name":"item2", "value":
"value2"}, {"name":"item2", "value": "value2update"}, {name:"item3",
"value": "value3"}] }
Thanks,
Fabrice
--
You received this message because you are subscribed to the Google Groups
"jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/d/optout.