diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2023-01-30 16:54:15 -0700 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2023-01-30 16:55:09 -0700 |
commit | 75a59f2b56982bc753d594a5af375b23ef786fdf (patch) | |
tree | 925d60b1151d0d788bcdcc414cc2d22c236bf62c /decode.go | |
parent | c24b34a47359ffb012b85e329f829b64d9d27215 (diff) |
decode: Tidy up DecodeObject and DecodeArray
Diffstat (limited to 'decode.go')
-rw-r--r-- | decode.go | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -878,9 +878,11 @@ func DecodeObject(r io.RuneScanner, decodeKey, decodeVal func(io.RuneScanner) er defer dec.posStackPop() l := dec.limitingScanner() if err := decodeKey(l); err != nil { + // TODO: Find a better Go type to use than `nil`. dec.panicType("string", nil, err) } if _, _, err := l.ReadRune(); err != io.EOF { + // TODO: Find a better Go type to use than `nil`. dec.panicType("string", nil, fmt.Errorf("did not consume entire string")) } }, @@ -890,13 +892,15 @@ func DecodeObject(r io.RuneScanner, decodeKey, decodeVal func(io.RuneScanner) er t := dec.peekRuneType() l := dec.limitingScanner() if err := decodeVal(l); err != nil { + // TODO: Find a better Go type to use than `nil`. dec.panicType(t.JSONType(), nil, err) } if _, _, err := l.ReadRune(); err != io.EOF { + // TODO: Find a better Go type to use than `nil`. dec.panicType(t.JSONType(), nil, fmt.Errorf("did not consume entire %s", t.JSONType())) } }) - return err + return nil } func (dec *Decoder) decodeObject(gTyp reflect.Type, decodeKey, decodeVal func()) { @@ -954,13 +958,15 @@ func DecodeArray(r io.RuneScanner, decodeMember func(r io.RuneScanner) error) (e t := dec.peekRuneType() l := dec.limitingScanner() if err := decodeMember(l); err != nil { + // TODO: Find a better Go type to use than `nil`. dec.panicType(t.JSONType(), nil, err) } if _, _, err := l.ReadRune(); err != io.EOF { + // TODO: Find a better Go type to use than `nil`. dec.panicType(t.JSONType(), nil, fmt.Errorf("did not consume entire %s", t.JSONType())) } }) - return + return nil } func (dec *Decoder) decodeArray(gTyp reflect.Type, decodeMember func()) { |