go - failed to json.marshal map with non string keys -
i want convert map[int]string
json
, thought json.marshal()
trick, fails saying unsupported type map[int]string
. whereas if utilize map
key string works fine.
http://play.golang.org/p/qhls9nt8qq
later on inspection of marshaller code, there explicit check see if key not string , returns unsupportedtypeerror
...
why can't utilize primitives keys? if json standard doesn't allow non string keys, shouldn't json.marshal
convert primitives string , utilize them keys ?
it's not because of go, because of json: json not back upwards else strings keys.
have grammar of json:
pair string : value string "" " chars "
the total grammar available on json website.
unfortunately, utilize integers keys, must convert them string beforehand, instance using strconv.itoa
: not json
bundle work.
json go
No comments:
Post a Comment