JokerResponse.json constructor

JokerResponse.json(
  1. Map<String, dynamic> json, {
  2. int statusCode = 200,
  3. Map<String, String> headers = const {},
  4. Duration? delay,
})

Creates a successful response with JSON body

Implementation

factory JokerResponse.json(
  Map<String, dynamic> json, {
  int statusCode = 200,
  Map<String, String> headers = const {},
  Duration? delay,
}) {
  final jsonHeaders = {
    'content-type': 'application/json; charset=utf-8',
    ...headers,
  };
  return JokerResponse(
    statusCode: statusCode,
    headers: jsonHeaders,
    body: jsonEncode(json),
    delay: delay,
  );
}