Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add serde attributes to the prost (Serialize/Deserialize JSON) #286

Closed
scalalang2 opened this issue Aug 19, 2022 · 3 comments
Closed

Add serde attributes to the prost (Serialize/Deserialize JSON) #286

scalalang2 opened this issue Aug 19, 2022 · 3 comments

Comments

@scalalang2
Copy link

scalalang2 commented Aug 19, 2022

I found that we can add some tags on generated struct during compilation.

Why don't we add attributes at build time like below?

tokio-rs/prost#75 (comment)

let mut config = prost_build::Config::new();
config.type_attribute(".", "#[derive(Serialize)]");
config.type_attribute(".", "#[serde(rename_all = \"camelCase\")]");
@tony-iqlusion
Copy link
Member

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.

@scalalang2
Copy link
Author

😢 😭 😭

I understand, I hope this feature to be included in the future

@tony-iqlusion
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants