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)
| 199 | // duplicate key. A found result leaves the final value in the sliding buffer. |
| 200 | // SYS-REQ-116 |
| 201 | func (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 |
| 231 | func (rp *ReaderParser) findObjectValue(keys []string, depth int) (bool, []byte, error) { |
no test coverage detected