veselov.sumy.ua > PHP > Ошибка Call to undefined function json_decode() или json_encode()

Ошибка Call to undefined function json_decode() или json_encode()


28.01.10.
Это значит, что у Вас не определяется функция json_decode() или json_encode(). А это может быть в случае если у вас php ниже 5.2.0.

Как это пофиксить без обновления:

Качаем либу http://mike.teczno.com/JSON.tar.gz

Вставляем где нужно:
if( !function_exists('json_encode') ) {
    function json_encode($data) {
        $json = new Services_JSON();
        return( $json->encode($data) );
    }
}

// Future-friendly json_decode
if( !function_exists('json_decode') ) {
    function json_decode($data, $bool) {
        if ($bool) {
            $json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
        } else {
            $json = new Services_JSON();
        }
        return( $json->decode($data) );
    }
}


Подключаем либу:
include("JSON.php");


Всо -) пс, ТыЦ Дэсять -)

Вернуться назад