encoding/json: doesn't deserialize json fields with underscores into struct's fields who's tag contains the underscore but the struct field name does not #9841
Labels
Comments
Your struct tag has the wrong syntax, but the issue tracker is not a support forum. Please ask these sorts of questions on the go-nuts@ mailing list or StackOverflow. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Json:
Go:
Given the above json and struct, the value
e.SomeID
will not be filled with the value4
.From the first of three rules listed at http://blog.golang.org/json-and-go:
If I change the struct definition to
Then, after Unmarshalling, e.Some_ID will contain
4
as expected.It appears that when an underscore is involved in the field in the json, tagging the struct's field with an underscore when the struct's field does not contain an underscore will not marshal that field. If the json contains an underscore, so must the struct's field and the tag is useless.
The text was updated successfully, but these errors were encountered: