Skip to content

Rust: Add a frame that can be used to self-describe an encoded JSON value #195

@leighmcculloch

Description

@leighmcculloch

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}.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions