writeJson method

void writeJson(
  1. StringSink sink
)

Streaming JSON encoder (#lzdartstreamingjson): writes the canonical JSON for this Delta directly into sink, avoiding the intermediate Map<String, Object> and the ops List allocation that toWire would produce. Byte-identical to jsonEncode(toWire()).

Implementation

void writeJson(StringSink sink) {
  sink
    ..write('{"base_epoch":')
    ..write(baseEpoch.toString())
    ..write(',"epoch":')
    ..write(epoch.toString())
    ..write(',"ops":[');
  for (var i = 0; i < ops.length; i++) {
    if (i > 0) sink.write(',');
    sink.write(jsonEncode(ops[i].toWire()));
  }
  sink.write(']}');
}