You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brpc.apache.org by "linjunmian (via GitHub)" <gi...@apache.org> on 2023/02/23 13:03:56 UTC

[I] set_always_print_primitive_fields will serialize all oneof data. (brpc)

linjunmian opened a new issue, #2135:
URL: https://github.com/apache/brpc/issues/2135

   **Describe the bug (描述bug)**
   there is proto3 message
   message Oneof {
       oneof data {
       string str1 = 1;
       string str2 = 2;
   }
   };
   message AA {
   uint32 b=1;
   Oneof c = 2;
   };
   and aa is an response to a restful service.
   And my b's right value is 0,so i use cntl->set_always_print_primitive_fields(true);  to serialize   b.
   but i find all of c are serialized though i only set the str1 value.
   So the json reponse is :
   {
       "b": 0,
       "service_result": {
          "str1":"xxx",
          "str2":""
       }
   }
   
   **To Reproduce (复现方法)**
   
   
   **Expected behavior (期望行为)**
   I think set_always_print_primitive_fields should not serialize    oneof data
   
   **Versions (各种版本)**
   OS:centos7
   Compiler:gcc11
   brpc:1.3.0
   protobuf:3
   
   **Additional context/screenshots (更多上下文/截图)**
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org