Valid keys for json.Mashall

49 views
Skip to first unread message

aschobel

unread,
Jan 15, 2012, 11:49:38 PM1/15/12
to golang-nuts
Howdy,

I ran into a bit of a curiosity with the encoding/json package.

encoding/json.Mashall doesn't encode a field if the tag has a '/' in
it

type SubscriptiontrackHandlerSettings struct {
Enable int `json:"enable"`
TextHtml string `json:"text/html"`
TextPlain string `json:"text/plain"`
}

http://weekly.golang.org/src/pkg/encoding/json/encode.go?s=3491:3534#L415

A JSON object should be able to have a key with a '/' in if you look
at http://www.json.org/

Should I submit a patch?

Cheers,
Andreas


The API in question is SendGrid's:

http://docs.sendgrid.com/documentation/api/smtp-api/developers-guide/

Brad Fitzpatrick

unread,
Jan 16, 2012, 12:16:29 PM1/16/12
to aschobel, golang-nuts
Good find.

File a bug first, with everything in this email.

Then if you'd like, file a fix following http://golang.org/doc/contribute.html , or we can fix it too.
Reply all
Reply to author
Forward
0 new messages