json encoding of unoin

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

json encoding of unoin

eng007
This post has NOT been accepted by the mailing list yet.
This post was updated on .
I have a union for favorite_number which could be a null or an int. When I jsonencode the object I get:

{"name": "Alyssa", "favorite_number": {"int": 7}, "favorite_color": null}

I am trying to get rid of the type indicator for the union, in this case the int, so that it becomes:

{"name": "Alyssa", "favorite_number": 7, "favorite_color": null}

avro schema:

{"name": "person", "type": "record",
           "fields": [
              {"name": "name", "type": "string"},
              {"name": "favorite_number", "type": ["null", "int"], "default": null},
              {"name": "favorite_color", "type": "string"}
           ]
   }


Is there a way to do this? Thanks!
Loading...