Standard library / math/big

big.Int.UnmarshalJSON()

Decode an integer JSON number into the receiver; malformed or noninteger values can return errors. This method writes to the receiver (use a separate destination to preserve inputs when needed). Expected stdout: '9007199254740993\n'.

Formal Syntax & Structure

go syntaxgo
func (z *Int) UnmarshalJSON(text []byte) error

Parameters & Attributes

NameTypeDescription
text[]byteEncoded textual input.

Return Value

error

Returns the result described above; see the example for the observed behavior.

Working Example

Example Snippetgo
package main
import (  "fmt"  "math/big")
func check(err error) {  if err != nil {    panic(err)  }}func main() {  z := new(big.Int)  check(z.UnmarshalJSON([]byte("9007199254740993")))  fmt.Println(z)}
Go Reference