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
I'm trying to convert a struct to a map, and can't figure out how to make it work.
Basically I have these structs:
type SQLStepResult struct { Queries []QueryResult `mapstructure:"queries"` } type QueryResult struct { Rows []map[string]any `mapstructure:"rows"` }
and I want to convert SQLStepResult to:
SQLStepResult
{ "queries": [ { "rows": [ // ... ] } ] }
But I always end up with Rows instead of rows.
Rows
rows
I tried using the undocumented mapstructure.RecursiveStructToMapHookFunc but it doesn't appear to do anything
mapstructure.RecursiveStructToMapHookFunc
Is there a solution?
Go playground for reference: https://go.dev/play/p/ZlTOw1mqnH5
The text was updated successfully, but these errors were encountered:
I think something needs to be done to handle slices/arrays here: https://github.com/go-viper/mapstructure/blob/main/mapstructure.go#L1008
I'll try to look into it but will probably need some help, the code is hard
Sorry, something went wrong.
Hm, that looks like a bug. I don't have a solution from the top of my head. I'll try to look into it when I find the time.
This is related to mitchellh#249. PR mitchellh#314 has a solution. It would be great if the solution in the PR is ported to this repo and merged.
No branches or pull requests
I'm trying to convert a struct to a map, and can't figure out how to make it work.
Basically I have these structs:
and I want to convert
SQLStepResult
to:But I always end up with
Rows
instead ofrows
.I tried using the undocumented
mapstructure.RecursiveStructToMapHookFunc
but it doesn't appear to do anythingIs there a solution?
Go playground for reference: https://go.dev/play/p/ZlTOw1mqnH5
The text was updated successfully, but these errors were encountered: