johnzon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Struberg <>
Subject enable 'deduplicateObjects' via Annotation?
Date Tue, 26 Sep 2017 12:25:04 GMT
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");
Person[] family = new Person[]{sarah, clemens};

Transformed to JSON this will now look like the following:

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 
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


View raw message