MCPcopy
hub / github.com/tinylib/msgp / ReadJSONNumberBytes

Function ReadJSONNumberBytes

msgp/read_bytes.go:1390–1402  ·  view source on GitHub ↗

ReadJSONNumberBytes tries to read a number from 'b' and return the value and the remaining bytes. Possible errors: - [ErrShortBytes] (too few bytes) - TypeError (not a number (int/float))

(b []byte)

Source from the content-addressed store, hash-verified

1388// - [ErrShortBytes] (too few bytes)
1389// - TypeError (not a number (int/float))
1390func ReadJSONNumberBytes(b []byte) (number json.Number, o []byte, err error) {
1391 if len(b) < 1 {
1392 return "", nil, ErrShortBytes
1393 }
1394 if i, o, err := ReadInt64Bytes(b); err == nil {
1395 return json.Number(strconv.FormatInt(i, 10)), o, nil
1396 }
1397 f, o, err := ReadFloat64Bytes(b)
1398 if err == nil {
1399 return json.Number(strconv.FormatFloat(f, 'f', -1, 64)), o, nil
1400 }
1401 return "", nil, TypeError{Method: NumberType, Encoded: getType(b[0])}
1402}

Callers 1

FuzzReadBytesFunction · 0.85

Calls 3

ReadInt64BytesFunction · 0.85
ReadFloat64BytesFunction · 0.85
getTypeFunction · 0.85

Tested by 1

FuzzReadBytesFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…