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

Method decodeInterface

decode_interface.go:18–37  ·  view source on GitHub ↗
(i *interface{})

Source from the content-addressed store, hash-verified

16}
17
18func (dec *Decoder) decodeInterface(i *interface{}) error {
19 start, end, err := dec.getObject()
20 if err != nil {
21 dec.cursor = start
22 return err
23 }
24
25 // if start & end are equal the object is a null, don't unmarshal
26 if start == end {
27 return nil
28 }
29
30 object := dec.data[start:end]
31 if err = json.Unmarshal(object, i); err != nil {
32 return err
33 }
34
35 dec.cursor = end
36 return nil
37}
38
39// @afiune Maybe return the type as well?
40func (dec *Decoder) getObject() (start int, end int, err error) {

Callers 4

DecodeInterfaceMethod · 0.95
InterfaceMethod · 0.95
UnmarshalFunction · 0.95
DecodeMethod · 0.95

Calls 2

getObjectMethod · 0.95
UnmarshalMethod · 0.80

Tested by

no test coverage detected