http://play.golang.org/p/lF2ZgAyxei
How do I escape comma in JSON tag in Go?
type AA struct {
MyStr string `json:"sub,ject"`
}
func main() {
jsonStr := `
{
"sub,ject": "I"
}
`
stt := new(AA)
json.Unmarshal([]byte(jsonStr), stt)
fmt.Println(stt)
t, _ := strconv.Unquote(jsonStr)
fmt.Println(t)
}
This does not grab the key and only returns empty results.
How do I escape the comma?
The code used by the JSON encoding package to parse field tags is in tags.go. This code splits the field name from the options at the first comma. It not possible to escape the comma.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With