replaced json_last_error() with ['error'] check for PHP versions below 5.3.0