johnzon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hendrik Dev <hendrikde...@gmail.com>
Subject Re: De/Serialization byte[]
Date Mon, 12 Jan 2015 21:04:30 GMT
On Mon, Jan 12, 2015 at 9:59 PM, Romain Manni-Bucau
<rmannibucau@gmail.com> wrote:
> it is on fields if configured in the builder (access).

@Target does not allow to be used on fields

--> @Target(**METHOD**)
@Retention(RUNTIME)
public @interface JohnzonConverter {
    Class<? extends Converter<?>> value();
}

> We can add
> class support as well but it is really a global (all class fields)
> option you want no?
>
>

why not?

>
> Romain Manni-Bucau
> @rmannibucau
> http://www.tomitribe.com
> http://rmannibucau.wordpress.com
> https://github.com/rmannibucau
>
>
> 2015-01-12 21:54 GMT+01:00 Hendrik Dev <hendrikdev22@gmail.com>:
>> jackson/genson use base64 by default for byte[] and in xml you would
>> "normally" serialize binary data also as base64.
>> so this is kind of "compatibility switch" to interoperate with json
>> which is de/serialized by other parsers
>> (nevertheless i this the johnzon primary default should be
>> de/serializing to int array -> "bytes":[1,2,3,4, ...] cause this the
>> "natural" style and would preserve the manner of an array type)
>>
>> But my superior point is to have a global option, so maybe we can
>> consider make @JohnzonConverter also applicable to classes (and fields
>> btw).
>>
>> On Mon, Jan 12, 2015 at 9:41 PM, Romain Manni-Bucau
>> <rmannibucau@gmail.com> wrote:
>>> got it but why base64, why not String or hexa? why priviledging one?
>>> Would supporting global @Converter (registered through builder) would
>>> help solving it?
>>>
>>>
>>> Romain Manni-Bucau
>>> @rmannibucau
>>> http://www.tomitribe.com
>>> http://rmannibucau.wordpress.com
>>> https://github.com/rmannibucau
>>>
>>>
>>> 2015-01-12 21:38 GMT+01:00 Hendrik Dev <hendrikdev22@gmail.com>:
>>>> dont know if i got it. my idea was to have a global switch
>>>> (treatByteArrayAsBase64) and then you can override this global switch
>>>> with @JohnzonConverter for specific fields/props
>>>>
>>>>
>>>> On Mon, Jan 12, 2015 at 9:16 PM, Romain Manni-Bucau
>>>> <rmannibucau@gmail.com> wrote:
>>>>> I wouldn't introduce treatByteArrayAsBase64 cause I want String
>>>>> instead - well not true but you get the point ;). JohnzonConverter
>>>>> should clearly work and should do the trick. I would just align 1-1 on
>>>>> java (ie byte = small int)
>>>>>
>>>>> wdyt?
>>>>>
>>>>>
>>>>> Romain Manni-Bucau
>>>>> @rmannibucau
>>>>> http://www.tomitribe.com
>>>>> http://rmannibucau.wordpress.com
>>>>> https://github.com/rmannibucau
>>>>>
>>>>>
>>>>> 2015-01-12 21:12 GMT+01:00 Hendrik Dev <hendrikdev22@gmail.com>:
>>>>>> see https://git-wip-us.apache.org/repos/asf?p=incubator-johnzon.git;a=commit;h=92098f4561c80a569c8349d8132369dcfa998e08
>>>>>>
>>>>>> Its not yet customizable with @JohnzonConverter, but its a general
>>>>>> option for the mapperbuilder.
>>>>>> I struggled with @JohnzonConverter but it its important because it
>>>>>> allows a more fine grained control
>>>>>>
>>>>>> default is int array
>>>>>>
>>>>>> On Mon, Jan 12, 2015 at 2:26 PM, Romain Manni-Bucau
>>>>>> <rmannibucau@gmail.com> wrote:
>>>>>>> +1 for ints (bytes actually ;)).
>>>>>>>
>>>>>>> this should still be customizable with @JohnzonConverter BTW
>>>>>>>
>>>>>>>
>>>>>>> Romain Manni-Bucau
>>>>>>> @rmannibucau
>>>>>>> http://www.tomitribe.com
>>>>>>> http://rmannibucau.wordpress.com
>>>>>>> https://github.com/rmannibucau
>>>>>>>
>>>>>>>
>>>>>>> 2015-01-12 13:17 GMT+01:00 Hendrik Dev <hendrikdev22@gmail.com>:
>>>>>>>> do we want to serialize a byte array into a sequence of int's
(eg
>>>>>>>> [2,5,0,9, ...]) or as a base64 encoded string? or we make
it
>>>>>>>> configurable and define a default?
>>>>>>>>
>>>>>>>> --
>>>>>>>> Hendrik Saly (salyh, hendrikdev22)
>>>>>>>> @hendrikdev22
>>>>>>>> PGP: 0x22D7F6EC
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Hendrik Saly (salyh, hendrikdev22)
>>>>>> @hendrikdev22
>>>>>> PGP: 0x22D7F6EC
>>>>
>>>>
>>>>
>>>> --
>>>> Hendrik Saly (salyh, hendrikdev22)
>>>> @hendrikdev22
>>>> PGP: 0x22D7F6EC
>>
>>
>>
>> --
>> Hendrik Saly (salyh, hendrikdev22)
>> @hendrikdev22
>> PGP: 0x22D7F6EC



-- 
Hendrik Saly (salyh, hendrikdev22)
@hendrikdev22
PGP: 0x22D7F6EC

Mime
View raw message