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

Embedded JSON in JSONRPC Responses #37

Open
mvandeberg opened this issue Jun 2, 2022 · 0 comments
Open

Embedded JSON in JSONRPC Responses #37

mvandeberg opened this issue Jun 2, 2022 · 0 comments
Labels

Comments

@mvandeberg
Copy link
Member

As a developer interfacing with the Koinos API via JSONRPC, I would like error responses to not contain stringified JSON.

e.g. Koinos Chain can return an error response that looks like this:

{"jsonrpc":"2.0","error":{"code":-32603,"message":"contract does not exist","data":"{\"code\":102}"},"id":1} (koinos/koinos-chain#677)

The problem is the "data":"{\"code\":102}"}. In order to programmatically interact with data, JSON must be parsed again.

We can change the proto error_response to better hold this data.

message error_response {
   string message = 1;
   map<string, google.protobuf.Any> data = 2;
}

Then, in jsonrpc, we can parse data and convert it to a golang map that can be encoded in json.

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

No branches or pull requests

1 participant