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

Function decodeJSONObject

pkg/util/json/encode.go:251–289  ·  view source on GitHub ↗
(containerHeader uint32, b []byte)

Source from the content-addressed store, hash-verified

249}
250
251func decodeJSONObject(containerHeader uint32, b []byte) ([]byte, JSON, error) {
252 length := int(containerHeader & containerHeaderLenMask)
253
254 b, jEntries, err := decodeJEntries(length*2, b)
255 if err != nil {
256 return b, nil, err
257 }
258
259 // There are `length` key entries at the start and `length` value entries at the back.
260 keyJEntries := jEntries[:length]
261 valueJEntries := jEntries[length:]
262
263 result := make(jsonObject, length)
264 // Decode the keys.
265 for i := 0; i < length; i++ {
266 var nextJSON JSON
267 b, nextJSON, err = decodeJSONValue(keyJEntries[i], b)
268 if err != nil {
269 return b, nil, err
270 }
271 if key, ok := nextJSON.(jsonString); ok {
272 result[i].k = key
273 } else {
274 return b, nil, errors.AssertionFailedf(
275 "key encoded as non-string: %T", nextJSON)
276 }
277 }
278
279 // Decode the values.
280 for i := 0; i < length; i++ {
281 var nextJSON JSON
282 b, nextJSON, err = decodeJSONValue(valueJEntries[i], b)
283 if err != nil {
284 return b, nil, err
285 }
286 result[i].v = nextJSON
287 }
288 return b, result, nil
289}
290
291func decodeJSONNumber(b []byte) ([]byte, JSON, error) {
292 b, d, err := encoding.DecodeUntaggedDecimalValue(b)

Callers 1

DecodeJSONFunction · 0.85

Calls 2

decodeJEntriesFunction · 0.85
decodeJSONValueFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…