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
time.Time encoded as map[string]interface{}{} #191
Comments
Hi @smyrman , |
I believe #183 should address this. |
Hello @mitchellh, firstly, thanks for this library. I've been trying to achieve something similar, converting from a struct into a I tried setting a new Are there any examples/hints on how this can be achieved? |
Agree with @yjwong; I don't quite see how #183 allows solving this problem. The problem is that after |
Having this same issue |
1 similar comment
Having this same issue |
mark this issue |
Same issue |
@johnny-oriente I recommend using |
@smyrman, Hi there! This new https://github.com/worldline-go/struct2 package may be of interest to you too. |
We have work-around this issue long ago by writing our own implementation of the struct / slice -> map[string]interface{} / []interface{} conversion path, and using mapstructure for the to struct path only. The struct2 |
@smyrman They are new kid on the block, so they might be willing to clean up. Their interface is not that big though, so renaming might be easy. |
Noticed that if encoding a struct into a map,
time.Time
entries are passed into empty maps, which doesn't seam very useful.I could add a hook to encode it into a string instance, but because hooks run as pre-processors, it's not possible to preserve it as a time.Time.
Example code:
Output:
The text was updated successfully, but these errors were encountered: