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 a frame that can be used to self-describe an encoded JSON value #195

Open
leighmcculloch opened this issue Apr 3, 2024 · 0 comments

Comments

@leighmcculloch
Copy link
Member

For the most part when the JSON generated by the Rust generated code is used, it is sufficient that the JSON is self-describing but not self identifying.

For example, when encoding an ScVal::I32(1), the JSON will be {"i32":1}.

As long as the decoder knows that the value is an ScVal they can decode the type.

There are some situations where it would be useful to be able to self identify the type that has been encoded, and for applications to have a common way to do that, such that it is part of the JSON schema.

For example in a form such as {"type":"ScVal","i32":1} or {"ScVal":{"i32":1}}.

It would also be convenient if that frame was extendable with arbitrary attributes. For the Stellar XDR use case specifically those additional attributes would include an XDR version number, such that applications that store JSON values longer term can identify which XDR<>JSON schema needs to be used to decode the value.

For example {"version":"20.0.0","type":"ScVal","i32":1}.

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

1 participant