grpcc icon indicating copy to clipboard operation
grpcc copied to clipboard

Value of oneof field is always null

Open c100k opened this issue 8 years ago • 3 comments

Hi,

There is a display bug with the oneof fields. Even if one of the values is set, it always displays null.

Example :

message Message1 {
    string name = 1;
    oneof example {
        Type1 value1 = 8;
        Type2 value2 = 9;
    }
}

Output :

{
  "name": "Dexter",
  "example": null
}

c100k avatar Jul 15 '17 05:07 c100k

Tried it locally, definitely an issue, but I think it's something to do with protobuf.js rather than grpcc:

https://github.com/grpc/grpc/issues/7200 https://github.com/google/protobuf/issues/1741

Both those bugs are closed but it's still broken even if I update all the deps. I'll need to take a deeper look.

njpatel avatar Oct 20 '17 18:10 njpatel

Hi, any update on this subject? I use oneof in my proto but I always get null. Thanks

chabmed avatar Jun 12 '18 03:06 chabmed

how could i shield null items in the response of grpcc? thanks the result below is my response, how could i retain the non-null values only? "requireKeywordsWithIndex": { "age": "", "backgrounds": [], "directions": [], "experiences": [], "certs": [], "workYears": [], "companyTypes": [], "gender": [], "industries": [], "locations": [], "majors": [], "maritialStatus": [], "salary": [], "schoolTypes": [], "stability": [], "targetCompany": [], "degrees": [], "degreeOthers": [], "intentType": [], "skills": [ "2.0年以上java编程(0)" ],

yuimo avatar Apr 18 '19 02:04 yuimo