I would imagine that most implementations are still going to use field
number order. Is there a specific reason you need to control it? Most JSON
tools won't care, and if you want to control the JSON, frankly you
shouldn't be using an opinionated serializer like protobuf - you should be
using a suitable highly configurable JSON-dedicated serializer for your
platform.

On Sun, 22 Mar 2020, 14:10 tuk, <[email protected]> wrote:

> Cross-posting from stackoverflow
> <https://stackoverflow.com/questions/60800326/how-to-control-the-order-of-field-while-converting-a-protobuf-message-to-string>
>
>  have a protobuf message which when converted to string using
> TextFormat.printToString()
>
> deploymentDef {
>   id: "PX3C1ED"
>   default: true
>   type: ONPREM
>   limits {
>     clusterSize: 3
>     limits {
>       numVMs: 18000
>       numVMsWithFlows: 18000
>       activeFlows: 6000000
>       totalFlows: 24000000
>       flowPlanning: 4000000
>       numDevices: 40
>     }
>   }
>   isEnterprise: false
>   brickSize: XLARGE
>   clusterSize: 3
>   description: "Default Role, Non-Enterprise, App-Discovery and Vf services 
> stopped"}
>
> The proto definition looks like below
>
> message DeploymentDef {
>     optional string id = 1;
>     optional bool default = 2;
>     optional DeploymentType type = 3;
>     optional PlatformClusterLimits limits = 4;
>     repeated Role roles = 5;
>     optional bool isEnterprise = 6;
>     optional Configs overrides = 7;
>     optional BrickSize brickSize = 8;
>     optional int32 clusterSize = 9;
>     optional string description = 10;}
>
> Is it possible to display description as the first field while converting
> the proto message to string using TextFormat.printToString() ?
>
>
>
> --
> 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 on the web visit
> https://groups.google.com/d/msgid/protobuf/a3e94ffc-3723-4b70-b647-15452f4f5731%40googlegroups.com
> <https://groups.google.com/d/msgid/protobuf/a3e94ffc-3723-4b70-b647-15452f4f5731%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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 on the web visit 
https://groups.google.com/d/msgid/protobuf/CAF95VAxzh%2BNa5HZ1-6UBsGMPUiY-Hc_Dc9_DTcg3wJsNkQ_o1Q%40mail.gmail.com.

Reply via email to