encoding/json: tags can't have Unicode punctuation #53267
Labels
Documentation
Issues describing a change to documentation.
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
What version of Go are you using (
go version
)?1.18.3
Does this issue reproduce with the latest release?
1.18.3 is the latest release at the time of writing
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Try to use a struct with a tag that has non-ASCII symbols in it, e.g.
https://go.dev/play/p/IwgJHZCedCE
What did you expect to see?
Tags can be anything, and JSON places no limits on this either (the name of a name/value pair is “a string”), and the encoding/json package mentions no limits, so I'd expect it to just work: the above playground link should produce
What did you see instead?
the tag is silently ignored and you get
this is because encoding/json's
isValidTag
only allows (some) ASCII symbols:go/src/encoding/json/encode.go
Lines 972 to 987 in 95b68e1
The text was updated successfully, but these errors were encountered: