WordPress at a glance
function is not described

WP_REST_Request::is_json_content_type() public WP 5.6.0

Checks if the request has specified a JSON content-type.

{} It's a method of the class: WP_REST_Request{}

No Hooks.

Return

true/false. True if the content-type header is JSON.

Usage

$WP_REST_Request = new WP_REST_Request();
$WP_REST_Request->is_json_content_type();

Changelog

Since 5.6.0 Introduced.

Code of WP_REST_Request::is_json_content_type() WP 5.6

<?php
public function is_json_content_type() {
	$content_type = $this->get_content_type();

	return isset( $content_type['value'] ) && wp_is_json_media_type( $content_type['value'] );
}