iterObject iterates through all the keys and values of an encoded object without requiring decoding of all of them.
()
| 267 | // iterObject iterates through all the keys and values of an encoded object |
| 268 | // without requiring decoding of all of them. |
| 269 | func (j *jsonEncoded) iterObject() (encodedObjectIterator, error) { |
| 270 | if j.typ != ObjectJSONType { |
| 271 | panic("can only iterate through the object values of an object") |
| 272 | } |
| 273 | |
| 274 | curKeyIdx := containerHeaderLen + j.containerLen*jEntryLen*2 |
| 275 | curValueIdx := curKeyIdx |
| 276 | |
| 277 | // We have to seek to the start of the value data. |
| 278 | for i := 0; i < j.containerLen; i++ { |
| 279 | entry, err := getJEntryAt(j.value, containerHeaderLen+i*jEntryLen, curValueIdx-curKeyIdx) |
| 280 | if err != nil { |
| 281 | return encodedObjectIterator{}, err |
| 282 | } |
| 283 | curValueIdx += int(entry.length) |
| 284 | } |
| 285 | |
| 286 | return encodedObjectIterator{ |
| 287 | curKeyIdx: 0, |
| 288 | keyOffset: curKeyIdx, |
| 289 | curValueIdx: 0, |
| 290 | valueOffset: curValueIdx, |
| 291 | len: j.containerLen, |
| 292 | idx: 0, |
| 293 | data: j.value, |
| 294 | }, nil |
| 295 | } |
| 296 | |
| 297 | func (j *jsonEncoded) StripNulls() (JSON, bool, error) { |
| 298 | dec, err := j.shallowDecode() |
no test coverage detected