users@jsonb-spec.java.net

[jsonb-spec users] Re: [jsr367-experts] Re: Re: [2-DefaultMapping] Proposal

From: Martin Vojtek <voytoo_at_gmail.com>
Date: Tue, 17 Mar 2015 10:08:14 +0100

I suggest the following default for inheritance, order of fields (for
default mapping):

1. Fields MUST be marshalled(serialized) in lexicographical order.
2. Fields of super class MUST be marshalled(serialized) before fields of
child class.
3. When unmarshalling, fields of super class MUST be set before fields of
child class.


ad examples: I will add examples for suggested cases. In general, feel free
to
send me diff file or create some github fork to propose changes/examples
and I will incorporate it (if you don't have commit rights).


MartinV

On Mon, Mar 16, 2015 at 2:03 PM, Przemyslaw Bielicki <pbielicki_at_gmail.com>
wrote:

> 1. Do we rellly want to specify ordering of POJO fields based on
>> lexicographic order of field names?
>> I think better rely on fields order of appearance in class as it done in
>> Gson.
>>
>
> Eugen is completely right here. The order is nor guaranteed in runtime.
>
>
>>
>> 2. Inheritance, order of fields. Should we specify default order of
>> fields when using inheritance? Which field set is to be first - fields of
>> subclass or fields of superclass? In gson superclass fields go first.
>>
>
> Good point. As usual let's come up with a reasonable and proved default +
> @Annotation to override it for advanced users.
>
>
>> 4. Lets add examples for POJO classes wth Collections/Arrays fields (one
>> to many relation).
>>
>>
> I think you're more than welcome to commit you changes :)
>
> Cheers,
> Przemyslaw
>
>
>