Add appends key value pair to the sequence and updates amount of memory allocated for the overall keys and values.
(k string, v JSON)
| 278 | // Add appends key value pair to the sequence and updates |
| 279 | // amount of memory allocated for the overall keys and values. |
| 280 | func (b *ObjectBuilderWithCounter) Add(k string, v JSON) { |
| 281 | b.ob.Add(k, v) |
| 282 | // Size of added JSON + overhead of storing key/value pair + the size of the key. |
| 283 | b.size += v.Size() + keyValuePairSize + uintptr(len(k)) |
| 284 | } |
| 285 | |
| 286 | // Build returns a JSON object built from a key value pair sequence. After that, |
| 287 | // it should not be modified any longer. |