Standard library / math/big
big.Int.MarshalJSON()
Encode an integer as a JSON number, not a quoted decimal string. Other decoders may lose precision. Expected stdout: '9007199254740993\n'.
Formal Syntax & Structure
go syntaxgo
func (x *Int) MarshalJSON() ([]byte, error)Return Value
([]byte, 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() { b, e := big.NewInt(9007199254740993).MarshalJSON() check(e) fmt.Println(string(b))}