wp_json_encode() – Encode a variable into JSON, with some sanity checks.
You appear to be a bot. Output may be restricted
Description
Encode a variable into JSON, with some sanity checks.
Usage
$string|false = wp_json_encode( $data, $options, $depth );
Parameters
- $data
- ( mixed ) required – Variable (usually an array or object) to encode as JSON.
- $options
- ( int ) optional – Optional. Options to be passed to json_encode(). Default 0.
- $depth
- ( int ) optional default: 512 – Optional. Maximum depth to walk through $data. Must be greater than 0. Default 512.
Returns
string|false The JSON encoded string, or false if it cannot be encoded.
Source
File name: wordpress/wp-includes/functions.php
Lines:
1 to 16 of 16
function wp_json_encode( $data, $options = 0, $depth = 512 ) { $json = json_encode( $data, $options, $depth ); // If json_encode() was successful, no need to do more sanity checking. if ( false !== $json ) { return $json; } try { $data = _wp_json_sanity_check( $data, $depth ); } catch ( Exception $e ) { return false; } return json_encode( $data, $options, $depth ); }