MCPcopy Create free account
hub / github.com/buger/jsonparser / findValue

Method findValue

reader_parser.go:201–228  ·  view source on GitHub ↗

findValue resolves keys[depth:] against the value at rp.pos. A not-found result consumes the current value so a containing object can continue past a duplicate key. A found result leaves the final value in the sliding buffer. SYS-REQ-116

(keys []string, depth int)

Source from the content-addressed store, hash-verified

199// duplicate key. A found result leaves the final value in the sliding buffer.
200// SYS-REQ-116
201func (rp *ReaderParser) findValue(keys []string, depth int) (bool, []byte, error) {
202 if err := rp.skipWhitespace(); err != nil {
203 if err == io.EOF {
204 return false, nil, MalformedJsonError
205 }
206 return false, nil, err
207 }
208 if depth == len(keys) {
209 raw, err := rp.captureValue()
210 return err == nil, raw, err
211 }
212
213 b, err := rp.peekByte(false)
214 if err != nil {
215 return false, nil, err
216 }
217 switch b {
218 case '{':
219 return rp.findObjectValue(keys, depth)
220 case '[':
221 return rp.findArrayValue(keys, depth)
222 default:
223 if err := rp.skipValue(); err != nil {
224 return false, nil, err
225 }
226 return false, nil, nil
227 }
228}
229
230// SYS-REQ-116
231func (rp *ReaderParser) findObjectValue(keys []string, depth int) (bool, []byte, error) {

Callers 3

GetMethod · 0.95
findObjectValueMethod · 0.95
findArrayValueMethod · 0.95

Calls 6

skipWhitespaceMethod · 0.95
captureValueMethod · 0.95
peekByteMethod · 0.95
findObjectValueMethod · 0.95
findArrayValueMethod · 0.95
skipValueMethod · 0.95

Tested by

no test coverage detected