You are here

protected function EasyRdf_Parser_Json::jsonLastErrorString in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/Json.php \EasyRdf_Parser_Json::jsonLastErrorString()

Return the last JSON parser error as a string

If json_last_error() is not available a generic message will be returned.

@ignore

1 call to EasyRdf_Parser_Json::jsonLastErrorString()
EasyRdf_Parser_Json::parse in vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/Json.php
Parse RDF/JSON into an EasyRdf_Graph

File

vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/Json.php, line 68

Class

EasyRdf_Parser_Json
A pure-php class to parse RDF/JSON with no dependancies.

Code

protected function jsonLastErrorString() {
  if ($this->jsonLastErrorExists) {
    switch (json_last_error()) {
      case JSON_ERROR_NONE:
        return null;
      case JSON_ERROR_DEPTH:
        return "JSON Parse error: the maximum stack depth has been exceeded";
      case JSON_ERROR_STATE_MISMATCH:
        return "JSON Parse error: invalid or malformed JSON";
      case JSON_ERROR_CTRL_CHAR:
        return "JSON Parse error: control character error, possibly incorrectly encoded";
      case JSON_ERROR_SYNTAX:
        return "JSON Parse syntax error";
      case JSON_ERROR_UTF8:
        return "JSON Parse error: malformed UTF-8 characters, possibly incorrectly encoded";
      default:
        return "JSON Parse error: unknown";
    }
  }
  else {
    return "JSON Parse error";
  }
}