json method

void json(
  1. Object? value
)

Sets the body to value encoded as JSON, and Content-Type: application/json unless headers already have a content type.

Implementation

void json(Object? value) {
  _content = jsonEncode(value);
  headers.putIfAbsent(
    HttpHeaders.contentTypeHeader,
    () => MediaType.applicationJson,
  );
}