json static method
Implementation
static Response json(Object? data, {int status = 200, Headers? headers}) {
final h = headers ?? Headers();
if (!h.has('content-type')) {
h.set('content-type', 'application/json; charset=utf-8');
}
// Encoded to UTF-8 as it is written: the same bytes as
// utf8.encode(jsonEncode(data)), without building the JSON text first
// and encoding it again -- about a third of what a small answer cost.
final List<int> encoded = _jsonUtf8.convert(data);
return Response.bytes(
status,
encoded is Uint8List ? encoded : Uint8List.fromList(encoded),
headers: h);
}