serialize method

Future<bool> serialize(
  1. dynamic value,
  2. {MediaType contentType}
)

Serializes data to the response.

Implementation

Future<bool> serialize(value, {MediaType contentType}) async {
  if (!isOpen) throw closed();
  this.contentType = contentType ?? MediaType('application', 'json');
  var text = await serializer(value);
  if (text.isEmpty) return true;
  write(text);
  await close();
  return false;
}