Is this supported by the python avro library?

It doesn't seem to be.

On 25 April 2018 at 17:02, Doug Cutting <[email protected]> wrote:

> To preserve type information, Avro's json encoding tags union values with
> their type.
>
> https://avro.apache.org/docs/current/spec.html#json_encoding
>
> If you wish to avoid this tagging, then you may use toString() on Avro
> data.  This will generate valid Json, although some type information may be
> lost in the case of unions.
>
> For example, a union of a string and an enum cannot always be losslessly
> converted to and from Json without tagging.  Nor can unions of ints and
> longs or unions of records and maps.  Avro's type model is more complex
> than Json's.  However if your schemas do not contain any unions that are
> ambiguous in Json then you can safely use toString().
>
> Doug
>
> On Wed, Apr 25, 2018 at 6:35 AM, amrishsintu <[email protected]>
> wrote:
>
>> Hi,
>>
>> I am trying to convert a POJO which is set with data to JSON in java.
>> While converting I get data as
>> "lastName": {
>>                     "string": "XYZ"
>>                 }
>> This happens when we use the following snippet of the schema.
>> "name": "lastName",
>> "type": ["string", "null"],
>>
>> But it works fine when we use below schema
>> "name": "lastName",
>> "type": ["string", "null"],
>> And produces result as :- lastName":  "XYZ"
>>
>> But we need to make the schema such that it should work properly even if
>> lastName comes as null.
>>
>> Please help us so that we can resolve the union issue of [“string”:”null”]
>>
>> Thanks,
>> Amrish
>>
>>
>>
>>
>> --
>> Sent from: http://apache-avro.679487.n3.nabble.com/Avro-Users-f679479.h
>> tml
>>
>
>


-- 
Marcelo Valle
http://mvalle.com - @mvallebr

Reply via email to