Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
encoding/json: Unmarshal isn't recognizing endashes in keys / struct tags #35287
What version of Go are you using (
Oh... (The information that you have provided should be a part of the ticket description (imho) - I missed unicode's thing.)
Is possible that editor (or source control) that you have used at some point got too smart, and replaced en dash with minus because it thought you are opening an ascii file instead of unicode? Like, visually they are (almost) the same...
If anything, there are more than one intermediary in between code and running binary - editors, compiler that understands the tags, json library itself, maybe some other. Sorry, I don't know how json is treated (by JSON spec, or by libraries) - does it allow to have UTF-8 tags?
I realized my ticket was too vague and added notes about the codepoints to the ticket. Thank you for the feedback.
If you run https://play.golang.org/p/VxJcyJXHyAd, I have it dump the raw bytes of the JSON. The en dash is UTF-8 encoded, and comes up as
According to the JSON spec at https://www.json.org/, the key to a JSON object must be a
However, if we look at https://golang.org/src/encoding/json/encode.go?s=6471:6514#L837, there's an