iterObject iterates through all the keys and values of an encoded object without requiring decoding of all of them.
()
| 253 | // iterObject iterates through all the keys and values of an encoded object |
| 254 | // without requiring decoding of all of them. |
| 255 | func (j *jsonEncoded) iterObject() (encodedObjectIterator, error) { |
| 256 | if j.typ != ObjectJSONType { |
| 257 | panic("can only iterate through the object values of an object") |
| 258 | } |
| 259 | |
| 260 | curKeyIdx := containerHeaderLen + j.containerLen*jEntryLen*2 |
| 261 | curValueIdx := curKeyIdx |
| 262 | |
| 263 | // We have to seek to the start of the value data. |
| 264 | for i := 0; i < j.containerLen; i++ { |
| 265 | entry, err := getJEntryAt(j.value, containerHeaderLen+i*jEntryLen, curValueIdx-curKeyIdx) |
| 266 | if err != nil { |
| 267 | return encodedObjectIterator{}, err |
| 268 | } |
| 269 | curValueIdx += int(entry.length) |
| 270 | } |
| 271 | |
| 272 | return encodedObjectIterator{ |
| 273 | curKeyIdx: 0, |
| 274 | keyOffset: curKeyIdx, |
| 275 | curValueIdx: 0, |
| 276 | valueOffset: curValueIdx, |
| 277 | len: j.containerLen, |
| 278 | idx: 0, |
| 279 | data: j.value, |
| 280 | }, nil |
| 281 | } |
| 282 | |
| 283 | func (j *jsonEncoded) StripNulls() (JSON, bool, error) { |
| 284 | dec, err := j.shallowDecode() |
no test coverage detected