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