letmegrpc icon indicating copy to clipboard operation
letmegrpc copied to clipboard

support oneof values

Open GeertJohan opened this issue 9 years ago • 11 comments

It looks like oneof is not supported. The JSON doesn't seem to be marshalled onto the oneof structure correctly. The oneof is ofcourse defined as interface field using the is_ type.

Maybe there's a custom unmarshal function required, or a different work arround (sending the oneof type and value as seperate json?

GeertJohan avatar Nov 12 '15 15:11 GeertJohan

No you found a missing feature. Well done :)

awalterschulze avatar Nov 12 '15 15:11 awalterschulze

I am on holiday, but I'll be back next week.

awalterschulze avatar Nov 12 '15 15:11 awalterschulze

I'm working on a solution.

GeertJohan avatar Nov 13 '15 15:11 GeertJohan

sorry about the code quality. I would really appreciate a pull request, but I would also totally understand if you find that the code is to horrible to edit. good luck On Nov 13, 2015 5:32 PM, "Geert-Johan Riemer" [email protected] wrote:

I'm working on a solution.

— Reply to this email directly or view it on GitHub https://github.com/gogo/letmegrpc/issues/10#issuecomment-156464607.

awalterschulze avatar Nov 13 '15 15:11 awalterschulze

Not at all. It will require some kind of workarround because json can't be directly marshalled onto protobuf onof fields.

GeertJohan avatar Nov 16 '15 07:11 GeertJohan

proto3 supports json as one of its serialization formats and proto3 has oneof, so we should check how the jsonpb package serializes oneof fields.

It is some of the hackiest code I have written in a while. Also one of my first projects with a significant amount of javascript. Luckily the user doesn't have to write the code so we are also using letmgerpc for about 4 guis at the moment. oneof would be a great additional feature.

awalterschulze avatar Nov 16 '15 08:11 awalterschulze

Any status update on this @GeertJohan ? Anything I can help with?

bobbytables avatar Jan 29 '16 19:01 bobbytables

@awalterschulze gogoproto /letmegrpc are both great and I'm really enjoying them.

Hey, I happened to hit this very bug in my project, and came to this bug report. Is there any progress for this? it would be great if this can be resolved soon. Thanks!

yangzh avatar Jul 13 '17 17:07 yangzh

There is no progress on this, but a contribution would be more than welcome.

awalterschulze avatar Jul 14 '17 08:07 awalterschulze

I don't know, why don't just use jsonpb for Unmarshal it? I just try replace err := json.Unmarshal([]byte(jsonString), msg) into err := jsonpb.UnmarshalString(jsonString, msg) and it just work fine (in my usecase)

tulequ avatar Jul 02 '18 09:07 tulequ

I think a lot of this was made just before jsonpb became popular. Does everything else keep on working?

awalterschulze avatar Jul 02 '18 11:07 awalterschulze