Zend\Diactoros\Response\JsonResponse::jsonEncode PHP Method

jsonEncode() private method

Encode the provided data to JSON.
private jsonEncode ( mixed $data, integer $encodingOptions ) : string
$data mixed
$encodingOptions integer
return string
    private function jsonEncode($data, $encodingOptions)
    {
        if (is_resource($data)) {
            throw new InvalidArgumentException('Cannot JSON encode resources');
        }
        // Clear json_last_error()
        json_encode(null);
        $json = json_encode($data, $encodingOptions);
        if (JSON_ERROR_NONE !== json_last_error()) {
            throw new InvalidArgumentException(sprintf('Unable to encode data to JSON in %s: %s', __CLASS__, json_last_error_msg()));
        }
        return $json;
    }