• Caleb Spare's avatar
    encoding/json: support maps with integer keys · f05c3aa2
    Caleb Spare authored
    This change makes encoding and decoding support integer types in map
    keys, converting to/from JSON string keys.
    
    JSON object keys are still sorted lexically, even though the keys may be
    integer strings.
    
    For backwards-compatibility, the existing Text(Un)Marshaler support for
    map keys (added in CL 20356) does not take precedence over the default
    encoding for string types. There is no such concern for integer types,
    so integer map key encoding is only used as a fallback if the map key
    type is not a Text(Un)Marshaler.
    
    Fixes #12529.
    
    Change-Id: I7e68c34f9cd19704b1d233a9862da15fabf0908a
    Reviewed-on: https://go-review.googlesource.com/22060Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
    f05c3aa2
decode.go 29.9 KB