(containerHeader uint32, b []byte)
| 249 | } |
| 250 | |
| 251 | func 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 | |
| 291 | func decodeJSONNumber(b []byte) ([]byte, JSON, error) { |
| 292 | b, d, err := encoding.DecodeUntaggedDecimalValue(b) |
no test coverage detected
searching dependent graphs…