Standard library / encoding/json

encoding/json.Number.Float64()

Convert the original number text to float64, potentially rounding or returning a range/syntax error. Expected stdout: '1.25\n'.

Formal Syntax & Structure

go syntaxgo
func (n Number) Float64() (float64, error)

Return Value

(float64, error)

Parsed float64 and conversion error.

Working Example

Example Snippetgo
package main
import (  "encoding/json"  "fmt")
func must(e error) {  if e != nil {    panic(e)  }}
func main() { x, e := json.Number("1.25").Float64(); must(e); fmt.Println(x) }
Go Reference