| 698 | } |
| 699 | |
| 700 | func (j jsonObject) Size() uintptr { |
| 701 | valSize := sliceHeaderSize + uintptr(cap(j))*keyValuePairSize |
| 702 | // jsonKeyValuePair consists of jsonString(i.e. string header) k and JSON interface v. |
| 703 | // Since elem.k.Size() has already taken stringHeaderSize into account, we should |
| 704 | // reduce len(j) * stringHeaderSize to avoid counting the size of string headers twice |
| 705 | valSize -= uintptr(len(j)) * stringHeaderSize |
| 706 | for _, elem := range j { |
| 707 | valSize += elem.k.Size() |
| 708 | valSize += elem.v.Size() |
| 709 | } |
| 710 | return valSize |
| 711 | } |
| 712 | |
| 713 | // ParseJSON takes a string of JSON and returns a JSON value. |
| 714 | func ParseJSON(s string) (JSON, error) { |