tokio-rs / prost

PROST! a Protocol Buffers implementation for the Rust Language
Apache License 2.0
3.86k stars 500 forks source link

Better `serde` support for Enumerations #1087

Open benj2468 opened 3 months ago

benj2468 commented 3 months ago

Currently, if a message has a field that is an enumeration, the field is provided as an i32 and tagged with something like the following:

#[prost(enumeration = "ENUMTYPE" tag = "1")]
field: i32,

This makes deserializing using serde difficult, as the field is type i32, but the standard for serializing proto to JSON is to the use name of the proto.

Has anyone encountered this before, or is there any incentive to make this easier in prost_build?

cynecx commented 3 months ago

cc https://github.com/tokio-rs/prost/pull/1081 (That PR implements proper proto-json support which will likely address this)