Re: More idiomatic JSON encoding for unions

2020-01-16 Thread Zoltan Farkas
I have hacked logical types in my fork to add this capability, if you want to take a look see: https://github.com/zolyfarkas/avro/blob/trunk/lang/java/avro/src/main/java/org/apache/avro/LogicalType.java#L78

Re: More idiomatic JSON encoding for unions

2020-01-16 Thread roger peppe
On Thu, 16 Jan 2020, 18:59 Zoltan Farkas, wrote: > answers inline > > On Jan 16, 2020, at 5:51 AM, roger peppe wrote: > > On Wed, 15 Jan 2020 at 18:51, Zoltan Farkas wrote: > >> What I mean with timestamp-micros, is that it is currently restricted to >> being bound to long, >> I see no reason w

Re: More idiomatic JSON encoding for unions

2020-01-16 Thread Zoltan Farkas
answers inline > On Jan 16, 2020, at 5:51 AM, roger peppe wrote: > > On Wed, 15 Jan 2020 at 18:51, Zoltan Farkas > wrote: > What I mean with timestamp-micros, is that it is currently restricted to > being bound to long, > I see no reason why it should not be allowe

Re: More idiomatic JSON encoding for unions

2020-01-16 Thread roger peppe
On Wed, 15 Jan 2020 at 18:51, Zoltan Farkas wrote: > What I mean with timestamp-micros, is that it is currently restricted to > being bound to long, > I see no reason why it should not be allowed to be bound to string as > well. (the change should be simple to implement) > Wouldn't have the impl

Re: More idiomatic JSON encoding for unions

2020-01-15 Thread Zoltan Farkas
What I mean with timestamp-micros, is that it is currently restricted to being bound to long, I see no reason why it should not be allowed to be bound to string as well. (the change should be simple to implement) regarding the media type, something like: application/avro.2+json would be fine. O

Re: More idiomatic JSON encoding for unions

2020-01-15 Thread roger peppe
On Wed, 15 Jan 2020 at 16:27, Zoltan Farkas wrote: > See comments in-line below: > > On Jan 15, 2020, at 3:42 AM, roger peppe wrote: > > Oops, I left arrays out! Two other thoughts: > > >- I wonder if it might be worth hedging bets about logical types. It >would be nice if (for example)

Re: More idiomatic JSON encoding for unions

2020-01-15 Thread Zoltan Farkas
See comments in-line bellow: > On Jan 15, 2020, at 3:42 AM, roger peppe wrote: > > Oops, I left arrays out! Two other thoughts: > > I wonder if it might be worth hedging bets about logical types. It would be > nice if (for example) a `timestamp-micros` value could be encoded as an > RFC3339

Re: More idiomatic JSON encoding for unions

2020-01-15 Thread roger peppe
Oops, I left arrays out! Two other thoughts: - I wonder if it might be worth hedging bets about logical types. It would be nice if (for example) a `timestamp-micros` value could be encoded as an RFC3339 string, so perhaps that should be allowed for, but maybe that's a step too far.

Re: More idiomatic JSON encoding for unions

2020-01-14 Thread roger peppe
On Tue, 14 Jan 2020 at 19:26, Zoltan Farkas wrote: > Makes sense, > > We have to agree on he scope of this implementation. > > Right now the implementation I have in java, handles only the: > > union {null, [some type]} situation. > > Are we ok with this for a start? > I'm not sure that it's wor

Re: More idiomatic JSON encoding for unions

2020-01-14 Thread Zoltan Farkas
Makes sense, We have to agree on he scope of this implementation. Right now the implementation I have in java, handles only the: union {null, [some type]} situation. Are we ok with this for a start? What I see more, is to handle: 1) union {string, double}, (although we have to specify behavi

Re: More idiomatic JSON encoding for unions

2020-01-14 Thread roger peppe
On Tue, 14 Jan 2020 at 15:00, Zoltan Farkas wrote: > I can go ahead create a PR to add the Encoder/Decoder implementations. > let me know if anyone else plans to do that. (to avoid wasting time) > Hi, Before you do that, would it be possible to write a specification for exactly what the convent

Re: More idiomatic JSON encoding for unions

2020-01-14 Thread Zoltan Farkas
I can go ahead create a PR to add the Encoder/Decoder implementations. let me know if anyone else plans to do that. (to avoid wasting time) thanks —Z > On Jan 9, 2020, at 3:51 AM, Driesprong, Fokko wrote: > > Thanks for chipping in Zoltan and Sean. I did not plan to change the current > JSON

Re: More idiomatic JSON encoding for unions

2020-01-09 Thread Driesprong, Fokko
Thanks for chipping in Zoltan and Sean. I did not plan to change the current JSON encoder. My initial suggestion would make this an option that the user can set. The default will be the current situation, so nothing should change when upgrading to a newer version of Avro. Cheers, Fokko Op wo 8 ja

Re: More idiomatic JSON encoding for unions

2020-01-08 Thread Sean Busbey
I agree with Zoltan here. We have a really long history of maintaining compatibility for encoders. On Tue, Jan 7, 2020 at 10:06 AM Zoltan Farkas wrote: > Fokko, > > I am not sure we should be changing the existing json encoder, > I think we should just add another encoder, and devs can use eithe

Re: More idiomatic JSON encoding for unions

2020-01-07 Thread Zoltan Farkas
Fokko, I am not sure we should be changing the existing json encoder, I think we should just add another encoder, and devs can use either one of them based on their use case… and stay backward compatible. we should maybe standardize the content types for them… I have seen application/avro bein

Re: More idiomatic JSON encoding for unions

2020-01-06 Thread Driesprong, Fokko
I would be a great fan of this as well. This also bothered me. The tricky part here is to see when to release this because it will break the existing JSON structure. We could make this configurable as well. Cheers, Fokko Op ma 6 jan. 2020 om 22:36 schreef roger peppe : > That's great, thanks! I

Re: More idiomatic JSON encoding for unions

2020-01-06 Thread roger peppe
That's great, thanks! I thought this would probably have come up before. Have you written down your changes in a somewhat more formal specification document, by any chance? cheers, rog. On Mon, 6 Jan 2020, 18:50 zoly farkas, wrote: > I think there is consensus that this should be implem

Re: More idiomatic JSON encoding for unions

2020-01-06 Thread zoly farkas
I think there is consensus that this should be implemented, see [AVRO-1582] Json serialization of nullable fileds and fields with default values improvement. - ASF JIRA | | | | [AVRO-1582] Json serialization of nullable fileds and fields with defaul... | | | Here is a live example

More idiomatic JSON encoding for unions

2020-01-06 Thread roger peppe
Hi, The JSON encoding in the specification includes an explicit type name for all kinds of object other than null. This means that a JSON-encoded Avro value with a union is very rarely directly compatible with normal JSON formats. For