MarshalJSON serializes the batch of events to JSON format.
()
| 33 | |
| 34 | // MarshalJSON serializes the batch of events to JSON format. |
| 35 | func (b *Batch) MarshalJSON() []byte { |
| 36 | buf := make([]byte, 0) |
| 37 | buf = append(buf, '[') |
| 38 | for i, evt := range b.Events { |
| 39 | writeMore := true |
| 40 | if i == len(b.Events)-1 { |
| 41 | writeMore = false |
| 42 | } |
| 43 | buf = append(buf, evt.MarshalJSON()...) |
| 44 | buf = append(buf, '\n') |
| 45 | if writeMore { |
| 46 | buf = append(buf, ',') |
| 47 | } |
| 48 | } |
| 49 | buf = append(buf, ']') |
| 50 | return buf |
| 51 | } |
no outgoing calls