protected function toJson($data, bool $ignoreErrors = false)
    {
        // suppress json_encode errors since it's twitchy with some inputs
        if ($ignoreErrors) {
            return @$this->jsonEncode($data);
        }

        $json = $this->jsonEncode($data);

        if ($json === false) {
            $json = $this->handleJsonError(json_last_error(), $data);
        }

        return $json;
    }
protected function toJson($data, bool $ignoreErrors = false)
    {
        // suppress json_encode errors since it's twitchy with some inputs
        if ($ignoreErrors) {
            return @$this->jsonEncode($data);
        }

        $json = $this->jsonEncode($data);

        if ($json === false) {
            $json = $this->handleJsonError(json_last_error(), $data);
        }

        return $json;
    }
protected function toJson ( $ data , bool $ ignoreErrors = false ) { // suppress json_encode errors since it's twitchy with some inputs if ( $ ignoreErrors ) { return @ $ this -> jsonEncode ( $ data ) ; } $ json = $ this -> jsonEncode ( $ data ) ; if ( $ json === false ) { $ json = $ this -> handleJsonError ( json_last_error ( ) , $ data ) ; } return $ json ; }
Return the JSON representation of a value

@param  mixed             $data
@throws \RuntimeException if encoding fails and errors are not ignored
@return string|bool
Return the JSON representation of a value