(containerHeader uint32, b []byte)
| 243 | } |
| 244 | |
| 245 | func decodeJSONObject(containerHeader uint32, b []byte) ([]byte, JSON, error) { |
| 246 | length := int(containerHeader & containerHeaderLenMask) |
| 247 | |
| 248 | b, jEntries, err := decodeJEntries(length*2, b) |
| 249 | if err != nil { |
| 250 | return b, nil, err |
| 251 | } |
| 252 | |
| 253 | // There are `length` key entries at the start and `length` value entries at the back. |
| 254 | keyJEntries := jEntries[:length] |
| 255 | valueJEntries := jEntries[length:] |
| 256 | |
| 257 | result := make(jsonObject, length) |
| 258 | // Decode the keys. |
| 259 | for i := 0; i < length; i++ { |
| 260 | e := keyJEntries[i] |
| 261 | if e.typCode != stringTag { |
| 262 | return b, nil, errors.AssertionFailedf( |
| 263 | "key encoded as non-string: %d", errors.Safe(e.typCode)) |
| 264 | } |
| 265 | // Inline string decoding from decodeJSONValue. This avoids the cost to pass |
| 266 | // through a JSON interface. |
| 267 | b, result[i].k = b[e.length:], jsonString(b[:e.length]) |
| 268 | } |
| 269 | |
| 270 | // Decode the values. |
| 271 | for i := 0; i < length; i++ { |
| 272 | var nextJSON JSON |
| 273 | b, nextJSON, err = decodeJSONValue(valueJEntries[i], b) |
| 274 | if err != nil { |
| 275 | return b, nil, err |
| 276 | } |
| 277 | result[i].v = nextJSON |
| 278 | } |
| 279 | return b, result, nil |
| 280 | } |
| 281 | |
| 282 | func decodeJSONNumber(b []byte) ([]byte, jsonNumber, error) { |
| 283 | b, d, err := encoding.DecodeUntaggedDecimalValue(b) |
no test coverage detected
searching dependent graphs…