We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
When encoding/decoding from data with slices of custom structs, they are ignored even thought the examples mention:
[...] struct [...] a slice or a pointer to a slice of one of the above types
Output:
map[name:[Name]]
map[name:[Name], id:[1 2], amount:[1 2]
var encoder = schema.NewEncoder() type Position struct { ID int64 `schema:"id"` Amount int64 `schema:"amount"` } type Document struct { Name string `schema:"name"` Positions []Position `schema:"position"` } func main() { person := Document{"Name", []Position{{1, 1}, {2, 2}}} form := url.Values{} encoder.Encode(person, form) fmt.Println(form) }
The text was updated successfully, but these errors were encountered:
I added an if to catch the error and it seems it's missing an encoder.
err := encoder.Encode(person, form) if err != nil { fmt.Println(err) }
schema: encoder not found for [{1 1} {2 2}]
Sorry, something went wrong.
So it seems that it's not a bug but I find the behavior rather odd because if I follow the docs they mention
So why do I need a custom encoder/decoder even tho my struct only contains supported fields (int64)?
int64
No branches or pull requests
Current Behavior
When encoding/decoding from data with slices of custom structs, they are ignored even thought the examples mention:
Output:
Expected Behavior
Output:
Steps To Reproduce
Output:
The text was updated successfully, but these errors were encountered: