Closed janewang closed 3 months ago
@janewang FYI unpackxdr
being at the top-level breaks the json-rpc spec. I updated the description here to move it to within params
. Cool with you?
@janewang @mollykarcher suggestion: asking the user to pass a parameter "format": "xdr" | "json"
rather than unpackxdr
@Shaptic I think that's where we started with. However, the format of the rpc response is technically already in JSON, with XDR strings.
xdr_format: "json" | "base64"
then? The idea is to not lock us into just JSON for unpacking XDR in the future :man_shrugging:
Fine with preserving the option to unpack XDR to another format. However, I think after we unpack to JSON, convert to other formats should not be the responsibility at this layer.
I think xdrFormat: "json" | "base64"
is reasonable.
Developers have the option to request data in JSON format. By default, responses are in the current XDR+JSON format unless specified otherwise in the request. If JSON format is requested, the system will dynamically convert the XDR data to JSON for easier readability and use by developers.
In order to:
'xdrFormat’: 'json'
in the request.xdrFormat
in the request, or include'xdrFormat': 'base64'
in the request. The response will return the current JSON and XDR in base64 string.The initial implementation is then backward compatible.
Example Usage for JSON response:
We have developed a canonical XDR ⇔ JSON schema for conversion between XDR and JSON: Stellar JSON
See https://docs.google.com/document/d/1tTuzL7HBHedp9TE-LonD1QV67SaBSReQ8YFj9xQIgtA/edit#heading=h.uedyb8nrk3a9