MCPcopy Create free account
hub / github.com/auxten/postgresql-parser / iterObject

Method iterObject

pkg/util/json/encoded.go:255–281  ·  view source on GitHub ↗

iterObject iterates through all the keys and values of an encoded object without requiring decoding of all of them.

()

Source from the content-addressed store, hash-verified

253// iterObject iterates through all the keys and values of an encoded object
254// without requiring decoding of all of them.
255func (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
283func (j *jsonEncoded) StripNulls() (JSON, bool, error) {
284 dec, err := j.shallowDecode()

Callers 1

shallowDecodeMethod · 0.95

Calls 1

getJEntryAtFunction · 0.85

Tested by

no test coverage detected