Hey all,

One thing that frustrated me when working with envoy grpc to json 
transcoding is that the field order in the output json message was decided 
using the tag numbers of the protobuf fields.

This is a bit problematic in cases where you want to make your json's more 
human readable - when adding fields that are expected to be located one 
near the other (think many fields, or even oneofs!) - tags are not meant to 
be changed, and order of fields in proto file can be freely changed, but 
json outputs can not. Changing tag values for this - is not an acceptable 
solution.

I tracked the issue down to the protobuf C library.

I suggest adding a new json print option:

preserve_descriptor_field_order

By default it will be false - so no behaviour change, but when true - 
fields will be ordered like in the descriptor (believe it or not, this is 
actually the default behavior, but then there is an explicit sort - using 
tag numbers!).

Added a test to showcase the feature.

See my PR, for all the details:
  https://github.com/protocolbuffers/protobuf/pull/19152

-- 
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 [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/protobuf/d9ca8b9e-4612-414b-a55d-68b7e964d1f3n%40googlegroups.com.

Reply via email to