users@jsonb-spec.java.net

[jsonb-spec users] [jsr367-experts] Re: JsonbTransient

From: Romain Manni-Bucau <rmannibucau_at_gmail.com>
Date: Wed, 13 Jan 2016 14:47:45 +0100

Hi Dmitry,

+1 to remove @JsonbTransient from class level

not sure what the inlining can bring compared to adapters too so +1 to just
remove it


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> | Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com>

2016-01-13 14:41 GMT+01:00 <dmitry.kornilov_at_oracle.com>:

> Hi experts,
>
> I have a question regarding @JsonbTransient annotation, declared on
> types. The behaviour as it described in the spec is unclear. The spec
> says:
>
> "When placed on a class, indicates that the class shouldn’t be mapped
> to JSON by itself. Properties on such class will be mapped to JSON
> along with its derived classes, as if the class is inlined."
>
> Here is some a sample illustrating it:
>
> class A {
> String aField;
> B b;
> }
>
> @JsonbTransient
> class B {
> String bField;
> }
>
> jsonb.toJson(A) -> {"aField":"someValue", "bField":"someValue"}
>
> If it's a desired behaviour I am not sure that it's a good idea to use
> "transient" keyword for inlining. Transient means "not serializable".
> So transient on a type would mean that this type is not serializable at
> all. The result of serializing the sample above will be:
>
> jsonb.toJson(A) -> {"aField":"someValue"}
>
> It's the same as putting @JsonbTransient on A.b field. I personally
> don't see it as a common use case.
>
> If we need inlining functionality maybe a better idea is to introduce
> something like @JsonbInline and restict usage of @JsonbTransient to
> fields only.
>
> What do you think?
>
> Thanks,
> Dmitry