encodeList static method

String encodeList(
  1. List<HeapSample> data
)

Given a list of HeapSample, encode as a Json string.

Implementation

static String encodeList(List<HeapSample> data) {
  final samplesJson = SamplesMemoryJson();
  final result = StringBuffer();

  // Iterate over all HeapSamples collected.
  data.map((f) {
    final encodedValue = result.isNotEmpty
        ? samplesJson.encodeAnother(f)
        : samplesJson.encode(f);
    result.write(encodedValue);
  }).toList();

  return '$header$result${MemoryJson.trailer}';
}