does MessageToJsonString give special treatment to struct.proto messages?

33 مرّة مشاهدة
التخطي إلى أول رسالة غير مقروءة

John Naylor

غير مقروءة،
18‏/12‏/2020، 9:57:10 ص18‏/12‏/2020
إلى Protocol Buffers
If I copy struct.proto into a different namespace and convert messages based on it to JSON, the conversion adds extra maps to the data.

message built using struct.proto:

string_param: {
 "oid": "HelloWorld",
 "name": "My nice parameter",
 "type": "STRING",
 "readonly": true,
 "widget": "default",
 "precision": 2,
 "value": "Evacuate the studio!"
}

message built using the same code but in a different namespace:

native_string_param: {
 "oid": "HelloWorld",
 "name": "My nice parameter",
 "type": "STRING",
 "readonly": true,
 "widget": "default",
 "precision": 2,
 "value": {
  "string_value": "Evacuate the studio!"
 }
}

note the extra "string_value" mapping.

Is there a way to have MessageToJsonString treat the second type of message the same way as it does struct.proto ones?

Thanks!

Adam Cozzette

غير مقروءة،
21‏/12‏/2020، 1:32:59 م21‏/12‏/2020
إلى John Naylor،Protocol Buffers
The Struct type is similar to some of the other well-known types like Timestamp and Duration which have their own custom JSON representation (see here). I'm afraid there is no easy way to replicate that functionality with a type other than Struct.

--
You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/protobuf/a62e3285-8951-463b-b424-629f4a43efc1n%40googlegroups.com.
الرد على الكل
رد على الكاتب
إعادة توجيه
0 رسالة جديدة