MCPcopy Index your code
hub / github.com/buger/jsonparser / GetFloat

Function GetFloat

parser.go:1265–1280  ·  view source on GitHub ↗

GetFloat returns the value retrieved by `Get`, cast to a float64 if possible. The offset is the same as in `Get`. If key data type do not match, it will return an error. SYS-REQ-004

(data []byte, keys ...string)

Source from the content-addressed store, hash-verified

1263// If key data type do not match, it will return an error.
1264// SYS-REQ-004
1265func GetFloat(data []byte, keys ...string) (val float64, err error) {
1266 v, t, _, e := Get(data, keys...)
1267
1268 if e != nil {
1269 return 0, e
1270 }
1271
1272 if t != Number {
1273 if t == Null {
1274 return 0, NullValueError
1275 }
1276 return 0, fmt.Errorf("Value is not a number: %s", string(v))
1277 }
1278
1279 return ParseFloat(v)
1280}
1281
1282// GetInt returns the value retrieved by `Get`, cast to a int64 if possible.
1283// If key data type do not match, it will return an error.

Callers 5

TestTypedGetterNilSafetyFunction · 0.85
FuzzGetFloatFunction · 0.85
TestGetFloatFunction · 0.85

Calls 2

GetFunction · 0.85
ParseFloatFunction · 0.85

Tested by 4

TestTypedGetterNilSafetyFunction · 0.68
TestGetFloatFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…