Documentation
¶
Overview ¶
Package jsnumber implements ECMAScript numeric conversion and serialization for values that arrive as JSON.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FromJSON ¶
FromJSON returns ToNumber of the value JSON.parse produces for raw. A nil or empty raw is undefined, which converts to NaN.
func JSON ¶
func JSON(value float64) json.RawMessage
JSON returns JSON.stringify(value): non-finite numbers serialize as null and -0 as 0.
func ParseInt ¶
ParseInt is Number.parseInt(text, 10): after JavaScript whitespace and an optional sign it reads the longest run of ASCII digits, and is NaN when none follows.
func Round ¶
Round is Math.round: the integral value nearest value, with halves toward +Infinity. A value in [-0.5, 0) rounds to -0, one in (0, 0.5) to +0, and NaN, infinities and zeros return unchanged. Unlike math.Floor(value+0.5), it does not round 0.49999999999999994 up or move an odd integer above 2^52, where the addition itself rounds.
func StringFromJSON ¶
StringFromJSON returns ToString (String(value)) of the value JSON.parse produces for raw. A nil or empty raw is undefined.
Types ¶
This section is empty.