WordPress at a glance
function is not described

_wp_json_prepare_data() WP 4.4.0

Prepares response data to be serialized to JSON.

This supports the JsonSerializable interface for PHP 5.2-5.3 as well.

No Hooks.

Return

true/false/Int/float/null/String/Array. Data ready for json_encode().

Usage

_wp_json_prepare_data( $data );
$data(mixed) (required)
Native representation.

Code of wp json prepare data: wp-includes/functions.php VER 5.1.1

<?php
function _wp_json_prepare_data( $data ) {
	if ( ! defined( 'WP_JSON_SERIALIZE_COMPATIBLE' ) || WP_JSON_SERIALIZE_COMPATIBLE === false ) {
		return $data;
	}

	switch ( gettype( $data ) ) {
		case 'boolean':
		case 'integer':
		case 'double':
		case 'string':
		case 'NULL':
			// These values can be passed through.
			return $data;

		case 'array':
			// Arrays must be mapped in case they also return objects.
			return array_map( '_wp_json_prepare_data', $data );

		case 'object':
			// If this is an incomplete object (__PHP_Incomplete_Class), bail.
			if ( ! is_object( $data ) ) {
				return null;
			}

			if ( $data instanceof JsonSerializable ) {
				$data = $data->jsonSerialize();
			} else {
				$data = get_object_vars( $data );
			}

			// Now, pass the array (or whatever was returned from jsonSerialize through).
			return _wp_json_prepare_data( $data );

		default:
			return null;
	}
}