Add serde attributes to the prost (Serialize/Deserialize JSON)
scalalang2 opened this issue · comments
I found that we can add some tags on generated struct during compilation.
Why don't we add attributes at build time like below?
let mut config = prost_build::Config::new();
config.type_attribute(".", "#[derive(Serialize)]");
config.type_attribute(".", "#[serde(rename_all = \"camelCase\")]");
We need to produce JSON which is either compatible with Amino or Protobuf JSON, and adding only Serialize
attribute on every struct in the generated code won’t get us all of the way there.
We need to pick which JSON serialization we're going to support and find a first-class solution for that.
As an example: Protobuf JSON uses Base64 to encode bytes
fields.
😢 😭 😭
I understand, I hope this feature to be included in the future
Yeah, I'm fine with adding JSON support. We just need to figure out the requirements and come up with a plan.
Closing this, and we can continue to discuss in #83.