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

Rust: Add JSON ser/der to all generated types #112

Closed
leighmcculloch opened this issue Jul 7, 2022 · 1 comment · Fixed by stellar/rs-stellar-xdr#99 or #117
Closed

Rust: Add JSON ser/der to all generated types #112

leighmcculloch opened this issue Jul 7, 2022 · 1 comment · Fixed by stellar/rs-stellar-xdr#99 or #117
Assignees

Comments

@leighmcculloch
Copy link
Member

We should make it easy to JSON serialize/deserialize the XDR types. This is somewhat controversial as there is no canonical format for JSON-to-XDR, so this would just be a Rust flavored JSON representation of the XDR for non-critical data use, and without any backwards compatible guarantees.

This should be added behind a feature flag so that none of the JSON functionality is included by default.

@sisuresh did some experimentation with serde_json and found it worked well:

sisuresh/rs-stellar-xdr@ebfd649#diff-20a7ada4b13b7b258fd3b69d364ba4a655f9988488e5f890094e75412b8591c6

We have to make a choice to flavor the resulting JSON fields names to be consistent with the Rust types, or consistent with the XDR. Both options are possible. The former is more aligned with the first paragraph of this issue, but the latter might make more sense too for any user of the JSON who is comparing it to the XDR. I'm inclined to lean towards the latter.

@leighmcculloch
Copy link
Member Author

I'm going to close this because this was done in #117, and separate issues exist now for follow work:

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

Successfully merging a pull request may close this issue.

2 participants