Future parse(Stream<List<int>> body, Encoding encoding)

Source

Future parse(Stream<List<int>> body, Encoding encoding) async {
  final asString = await body.map(encoding.decode).join('\n');
  final output = JSON.decode(asString);
  if (output is Map<String, dynamic>) {
    return new Map.unmodifiable(output);
  } else if (output is Iterable) {
    return new List.unmodifiable(output);
  }
  return output;
}