Documentation
¶
Overview ¶
Package json provides JSON serialization utilities for numeric types and a gorilla/rpc Codec that normalizes lowercase method names.
Index ¶
Constants ¶
const Null = "null"
Null is the string representation of the JSON null literal.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Float32 ¶
type Float32 float32
Float32 is a float32 that marshals/unmarshals as a JSON string with 4 digit fixed-point precision.
func (Float32) MarshalJSON ¶
func (*Float32) UnmarshalJSON ¶
type Float64 ¶
type Float64 float64
Float64 is a float64 that marshals/unmarshals as a JSON string.
func (Float64) MarshalJSON ¶
func (*Float64) UnmarshalJSON ¶
type Time ¶
type Time struct {
// Seconds is seconds since the epoch.
Seconds int64 `json:"seconds"`
// Nanos is the nanosecond within that second.
Nanos int32 `json:"nanos"`
// Offset is seconds east of UTC.
Offset int32 `json:"offset"`
}
Time is an instant, on a wire whose fields are offsets.
time.Time cannot be one. Its fields are all unexported, so a reply that holds one lays out with nothing in it — eight bytes pointing at an empty message — and a caller reads a zero it cannot tell from a zero that was sent. That is worse than a refusal: nothing fails and the value is simply absent.
The same instant as three numbers does have a layout. The JSON is byte for byte what time.Time's own marshaler writes, because the offset is all the rendering depends on: RFC 3339 spells a zero offset "Z" and any other one "+HH:MM", so carrying it is enough to put the instant back in the zone it was read in.
func (Time) MarshalJSON ¶
func (*Time) UnmarshalJSON ¶
type Uint8 ¶
type Uint8 uint8
Uint8 is a uint8 that marshals/unmarshals as a JSON string.
func (Uint8) MarshalJSON ¶
func (*Uint8) UnmarshalJSON ¶
type Uint16 ¶
type Uint16 uint16
Uint16 is a uint16 that marshals/unmarshals as a JSON string.
func (Uint16) MarshalJSON ¶
func (*Uint16) UnmarshalJSON ¶
type Uint32 ¶
type Uint32 uint32
Uint32 is a uint32 that marshals/unmarshals as a JSON string.
func (Uint32) MarshalJSON ¶
func (*Uint32) UnmarshalJSON ¶
type Uint64 ¶
type Uint64 uint64
Uint64 is a uint64 that marshals/unmarshals as a JSON string.
func (Uint64) MarshalJSON ¶
func (*Uint64) UnmarshalJSON ¶
type Uint256 ¶
Uint256 is a 256-bit unsigned integer that marshals/unmarshals as a JSON string, like the narrower widths beside it.
This is the width the EVM carries. A wei value, a token balance or a supply does not fit in 64 bits — an 18-decimal balance passes 2^64 at about 18.4 tokens — so a field of that shape reaching this boundary previously had to be a bare string or a hand-rolled big.Int at every site.
uint256.Int rather than big.Int: a fixed-size value cannot be nil, so a zero Uint256 is zero rather than a panic, and it does not allocate.