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

Method getObject

decode_interface.go:40–113  ·  view source on GitHub ↗

@afiune Maybe return the type as well?

()

Source from the content-addressed store, hash-verified

38
39// @afiune Maybe return the type as well?
40func (dec *Decoder) getObject() (start int, end int, err error) {
41 // start cursor
42 for ; dec.cursor < dec.length || dec.read(); dec.cursor++ {
43 switch dec.data[dec.cursor] {
44 case ' ', '\n', '\t', '\r', ',':
45 continue
46 // is null
47 case 'n':
48 dec.cursor++
49 err = dec.assertNull()
50 if err != nil {
51 return
52 }
53 // Set start & end to the same cursor to indicate the object
54 // is a null and should not be unmarshal
55 start = dec.cursor
56 end = dec.cursor
57 return
58 case 't':
59 start = dec.cursor
60 dec.cursor++
61 err = dec.assertTrue()
62 if err != nil {
63 return
64 }
65 end = dec.cursor
66 dec.cursor++
67 return
68 // is false
69 case 'f':
70 start = dec.cursor
71 dec.cursor++
72 err = dec.assertFalse()
73 if err != nil {
74 return
75 }
76 end = dec.cursor
77 dec.cursor++
78 return
79 // is an object
80 case '{':
81 start = dec.cursor
82 dec.cursor++
83 end, err = dec.skipObject()
84 dec.cursor = end
85 return
86 // is string
87 case '"':
88 start = dec.cursor
89 dec.cursor++
90 start, end, err = dec.getString()
91 start--
92 dec.cursor = end
93 return
94 // is array
95 case '[':
96 start = dec.cursor
97 dec.cursor++

Callers 1

decodeInterfaceMethod · 0.95

Calls 9

readMethod · 0.95
assertNullMethod · 0.95
assertTrueMethod · 0.95
assertFalseMethod · 0.95
skipObjectMethod · 0.95
getStringMethod · 0.95
skipArrayMethod · 0.95
skipNumberMethod · 0.95
raiseInvalidJSONErrMethod · 0.95

Tested by

no test coverage detected