users@jsonb-spec.java.net

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

From: Inderjeet Singh <inder_at_alumni.stanford.edu>
Date: Wed, 13 Jan 2016 23:28:49 -0800

Agreed. Semantics of transient should stay non-serializable.
If you want to support it on a class, it should make the class instances
non-serializable. It will be problematic to support it when serializing
arrays, but you can substitute nulls.
Probably better to drop it from class in v1, and consider adding it in
future.


On Wed, Jan 13, 2016 at 6:41 AM, Dmitry Kornilov <dmitry.kornilov_at_oracle.com
> wrote:

> I never met such a use case. IMHO, it's very rare and it doesn't worth
> supporting it. Adapters can be used as a workaround anyway.
>
> Dmitry
>
> Отправлено с iPhone
>
> 13 янв. 2016 г., в 15:14, Romain Manni-Bucau <rmannibucau_at_tomitribe.com>
> написал(а):
>
> In term of API not using "transient" to say it is not transient would be
> better (so @JsonIncluded or something different semantically from
> transient) but in term of use case I never saw "excluding all but" strategy
> for json. Anyone used it?
>
>
> Romain Manni-Bucau
> @rmannibucau
> http://www.tomitribe.com
> http://rmannibucau.wordpress.com
> https://github.com/rmannibucau
>
> 2016-01-13 14:57 GMT+01:00 Rahman USTA <rahman.usta.88_at_gmail.com>:
>
>> I actually like applying @JsonbTransient as class level. But, there may
>> be some circumstances that users may want to serialize fields that its
>> class has @JsonbTransient.
>>
>> For the Dmitry's example;
>>
>> class A {
>> String aField;
>> @JsonbTransient(transient=false) // Attention
>> B b;
>> }
>>
>> @JsonbTransient
>> class B {
>> String bField;
>> }
>>
>> @JsonbTransient annotation may have a transient property that is
>> default=true , and users may change this behaviour by setting the transient
>> property like above.
>>
>> What do you all think?
>>
>> 2016-01-13 15:47 GMT+02:00 Romain Manni-Bucau <rmannibucau_at_gmail.com>:
>>
>>> 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
>>>
>>>
>>>
>>
>>
>> --
>> Rahman USTA
>> Istanbul JUG
>> https://github.com/rahmanusta <http://www.kodcu.com/>
>>
>
>