(appendTo []byte)
| 79 | } |
| 80 | |
| 81 | func (j jsonArray) encode(appendTo []byte) (e jEntry, b []byte, err error) { |
| 82 | encodingStartPosition := len(appendTo) |
| 83 | // Array container header. |
| 84 | appendTo = encoding.EncodeUint32Ascending(appendTo, arrayContainerTag|uint32(len(j))) |
| 85 | // Reserve space for the JEntries and store where they start so we can fill them in later. |
| 86 | jEntryIdx := len(appendTo) |
| 87 | for i := 0; i < len(j); i++ { |
| 88 | appendTo = append(appendTo, 0, 0, 0, 0) |
| 89 | } |
| 90 | offset := uint32(0) |
| 91 | for i := 0; i < len(j); i++ { |
| 92 | var nextJEntry jEntry |
| 93 | nextJEntry, appendTo, err = j[i].encode(appendTo) |
| 94 | if err != nil { |
| 95 | return jEntry{}, appendTo, err |
| 96 | } |
| 97 | |
| 98 | length := nextJEntry.length |
| 99 | offset += length |
| 100 | |
| 101 | appendTo = encoding.PutUint32Ascending(appendTo, nextJEntry.encoded(encodingModeForIdx(i, offset)), jEntryIdx+i*4) |
| 102 | } |
| 103 | lengthInBytes := len(appendTo) - encodingStartPosition |
| 104 | if err := checkLength(lengthInBytes); err != nil { |
| 105 | return jEntry{}, b, err |
| 106 | } |
| 107 | return makeContainerJEntry(lengthInBytes), appendTo, nil |
| 108 | } |
| 109 | |
| 110 | func (j jsonObject) encode(appendTo []byte) (e jEntry, b []byte, err error) { |
| 111 | encodingStartPosition := len(appendTo) |
nothing calls this directly
no test coverage detected