Hi folks!

First of all, what does 'deduplicateObjects' do?

When switched on, it will effectively serialise any Object (other than a native 
or a JsonValue) only once.
Any further occurence in the Object-graph will be serialised as JsonPointer.

Person sarah = new Person("Sarah");
Person clemens = new Person("Clemens");
clemens.setMother(sarah);
Person[] family = new Person[]{sarah, clemens};

Transformed to JSON this will now look like the following:
[{"name":"Sarah"},{"name":"Clemens","mother":"/0"}]

Notice the "/0" which is a JsonPointer to Sarah.


Sometimes it's not feasible to enable the 'deduplicateObjects' feature on a 
general base.
E.g. when used with JsonB in JAX-RS we probably only want to use it when 
serialising a few specific objects.

Should we somehow support toggling this feature via an Annotation?
And how does this look like?

I think we don't need to ship this for 1.1.4, but we should take a bit time and 
look at it from a broader perspective.

This feature can now be enabled via 
MapperBuilder#setDeduplicateObjects(true);
ConfigurableJohnzonProvider for JAX-RS and
JsonbConfig.setProperty("johnzon.deduplicateObjects", true);

I think we're good to go for 1.1.4 and then improve with the annotation driven 
idea later on.

LieGrue,
strub

Reply via email to