Skip to content

json2: map by-position params onto struct fields - #104

Open
team-humaki wants to merge 1 commit into
gorilla:mainfrom
team-humaki:json2-positional-struct-params
Open

team-humaki wants to merge 1 commit into
gorilla:mainfrom
team-humaki:json2-positional-struct-params

Conversation

@team-humaki

Copy link
Copy Markdown

Fixes #84

JSON-RPC 2.0 by-position params is an array of values in the method's expected order. ReadRequest already unmarshals a one-element array of an object into the args struct, but a real positional array such as ["Hello world", 10, false] failed because encoding/json will not fill a struct from a JSON array.

After that wrap fails, map array elements onto exported fields (skipping unexported ones). By-name object params and the existing one-element wrap still work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] Unmarshaling arrays items to struct for json rpc 2.

1 participant