wpseek.com
				A WordPress-centric search engine for devs and theme authors
			wp_json_encode › WordPress Function
Since4.1.0
Deprecatedn/a
› wp_json_encode ( $value, $flags = 0, $depth = 512 )
| Parameters: (3) | 
 | 
| Returns: | 
 | 
| Defined at: | 
 | 
| Codex: | |
| Change Log: | 
 | 
Encodes a variable into JSON, with some confidence checks.
Related Functions: wp_json_file_decode, wp_is_json_media_type, wp_is_json_request, wp_send_json_error, wp_setcookie
	Source
function wp_json_encode( $value, $flags = 0, $depth = 512 ) {
	$json = json_encode( $value, $flags, $depth );
	// If json_encode() was successful, no need to do more confidence checking.
	if ( false !== $json ) {
		return $json;
	}
	try {
		$value = _wp_json_sanity_check( $value, $depth );
	} catch ( Exception $e ) {
		return false;
	}
	return json_encode( $value, $flags, $depth );
}