json<ST> static method

StringResponse json<ST>(
  1. ST value, {
  2. dynamic serializeWith(
    1. ST value
    )?,
  3. int statusCode = HttpStatus.ok,
  4. Map<String, dynamic>? headers,
  5. String mimeType = MimeTypes.json,
  6. String charset = kDefaultCharset,
  7. List<Cookie>? cookies,
})

Implementation

static StringResponse json<ST>(
  ST value, {
  dynamic serializeWith(ST value)?,
  int statusCode = HttpStatus.ok,
  Map<String, dynamic>? headers,
  String mimeType = MimeTypes.json,
  String charset = kDefaultCharset,
  List<Cookie>? cookies,
}) {
  String body =
      cnv.json.encode(serializeWith == null ? value : serializeWith(value));
  return StringResponse(
    body: body,
    statusCode: statusCode,
    headers: headers,
    mimeType: mimeType,
    charset: charset,
    cookies: cookies,
  );
}