You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 22, 2024. It is now read-only.
Repository navigation
This repository was archived by the owner on Jul 22, 2024. It is now read-only.
Encode a struct with ",remain" back to a map?Β #279
I have a use case where I need to decode a JSON, where I care only about a few fields, change it here and there, and then serialize it back to JSON. However, the remainder values seem to get serialized into an empty "" JSON field. This is my code:
Looks like the behavior has changed in 1.5.0. Now my Other fields are serialized not as "", but as "Other". (It doesn't solve the problem of course, but requires changing the workaround.)
Yeah, there was a bug fixed in 1.5.0 that caused some struct fields to get an empty string in the map. So you're seeing that fix, while still retaining your bug. We just need to turn your repro into a test case, and get a fix on top of it.
Activity
kszafran commentedon Apr 7, 2022
For now I'm using this simple workaround:
kszafran commentedon Apr 21, 2022
Looks like the behavior has changed in 1.5.0. Now my
Otherfields are serialized not as"", but as"Other". (It doesn't solve the problem of course, but requires changing the workaround.)mitchellh commentedon Apr 21, 2022
Yeah, there was a bug fixed in 1.5.0 that caused some struct fields to get an empty string in the map. So you're seeing that fix, while still retaining your bug. We just need to turn your repro into a test case, and get a fix on top of it.
Fix Encoding Struct Back to Map Bug (mitchellh#279)
tschaub commentedon Mar 7, 2023
#307 looks like a nice fix for this issue.
Arsen204 commentedon May 28, 2023
@mitchellh can we merge #307? it's a tested by prod fix :)
Merge pull request #8 from go-viper/decode-remaining-fields