johnzon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Romain Manni-Bucau <rmannibu...@gmail.com>
Subject Re: enable 'deduplicateObjects' via Annotation?
Date Tue, 26 Sep 2017 12:30:53 GMT
+0


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<https://blog-rmannibucau.rhcloud.com> | Old Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | JavaEE Factory
<https://javaeefactory-rmannibucau.rhcloud.com>

2017-09-26 14:25 GMT+02:00 Mark Struberg <struberg@yahoo.de.invalid>:

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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message