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