MCPcopy Create free account
hub / github.com/francoispqt/gojay / decodeFloat64Null

Method decodeFloat64Null

decode_number_float.go:50–93  ·  view source on GitHub ↗
(v **float64)

Source from the content-addressed store, hash-verified

48 return dec.raiseInvalidJSONErr(dec.cursor)
49}
50func (dec *Decoder) decodeFloat64Null(v **float64) error {
51 for ; dec.cursor < dec.length || dec.read(); dec.cursor++ {
52 switch c := dec.data[dec.cursor]; c {
53 case ' ', '\n', '\t', '\r', ',':
54 continue
55 case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
56 val, err := dec.getFloat()
57 if err != nil {
58 return err
59 }
60 if *v == nil {
61 *v = new(float64)
62 }
63 **v = val
64 return nil
65 case '-':
66 dec.cursor = dec.cursor + 1
67 val, err := dec.getFloatNegative()
68 if err != nil {
69 return err
70 }
71 if *v == nil {
72 *v = new(float64)
73 }
74 **v = -val
75 return nil
76 case 'n':
77 dec.cursor++
78 err := dec.assertNull()
79 if err != nil {
80 return err
81 }
82 return nil
83 default:
84 dec.err = dec.makeInvalidUnmarshalErr(v)
85 err := dec.skipData()
86 if err != nil {
87 return err
88 }
89 return nil
90 }
91 }
92 return dec.raiseInvalidJSONErr(dec.cursor)
93}
94
95func (dec *Decoder) getFloatNegative() (float64, error) {
96 // look for following numbers

Callers 3

Float64NullMethod · 0.95
UnmarshalFunction · 0.95
DecodeMethod · 0.95

Calls 7

readMethod · 0.95
getFloatMethod · 0.95
getFloatNegativeMethod · 0.95
assertNullMethod · 0.95
skipDataMethod · 0.95
raiseInvalidJSONErrMethod · 0.95

Tested by

no test coverage detected