_wp_json_sanity_check example


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 );
}

/** * Performs sanity checks on data that shall be encoded to JSON. * * @ignore * @since 4.1.0 * @access private * * @see wp_json_encode() * * @throws Exception If depth limit is reached. * * @param mixed $data Variable (usually an array or object) to encode as JSON. * @param int $depth Maximum depth to walk through $data. Must be greater than 0. * @return mixed The sanitized data that shall be encoded to JSON. */
Home | Imprint | This part of the site doesn't use cookies.