jsonResponse function
Encodes value as a JSON response.
Anything deriving Serialize is written through Serializable.serialize,
including nested values and the elements of a list, so a handler answers
with the model it already has:
return jsonResponse(repository.all());
Implementation
Response jsonResponse(Object? value, {int status = 200}) {
return Response(
status,
body: jsonEncode(value, toEncodable: _encode),
headers: const {'content-type': 'application/json'},
);
}