-
- Downloads
json: add struct tag option to wrap literals in strings
Since JavaScript doesn't have [u]int64 types, some JSON APIs encode such types as strings to avoid losing precision. This adds a new struct tag option ",string" to cause fields to be wrapped in JSON strings on encoding and unwrapped from strings when decoding. R=rsc, gustavo CC=golang-dev https://golang.org/cl/4918051
Showing
- src/pkg/json/Makefile 1 addition, 0 deletionssrc/pkg/json/Makefile
- src/pkg/json/decode.go 18 additions, 14 deletionssrc/pkg/json/decode.go
- src/pkg/json/decode_test.go 5 additions, 0 deletionssrc/pkg/json/decode_test.go
- src/pkg/json/encode.go 41 additions, 18 deletionssrc/pkg/json/encode.go
- src/pkg/json/encode_test.go 38 additions, 0 deletionssrc/pkg/json/encode_test.go
- src/pkg/json/tags.go 44 additions, 0 deletionssrc/pkg/json/tags.go
- src/pkg/json/tags_test.go 28 additions, 0 deletionssrc/pkg/json/tags_test.go
Loading
Please register or sign in to comment