MCPcopy
hub / github.com/bitly/go-simplejson / Float64

Method Float64

simplejson_reader.go:29–41  ·  view source on GitHub ↗

Float64 coerces into a float64

()

Source from the content-addressed store, hash-verified

27
28// Float64 coerces into a float64
29func (j *Json) Float64() (float64, error) {
30 switch j.data.(type) {
31 case json.Number:
32 return j.data.(json.Number).Float64()
33 case float32, float64:
34 return reflect.ValueOf(j.data).Float(), nil
35 case int, int8, int16, int32, int64:
36 return float64(reflect.ValueOf(j.data).Int()), nil
37 case uint, uint8, uint16, uint32, uint64:
38 return float64(reflect.ValueOf(j.data).Uint()), nil
39 }
40 return 0, errors.New("invalid value type")
41}
42
43// Int coerces into an int
44func (j *Json) Int() (int, error) {

Callers 2

MustFloat64Method · 0.95
TestSimplejsonFunction · 0.80

Calls 1

IntMethod · 0.80

Tested by 1

TestSimplejsonFunction · 0.64