Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: Zend_Json_Server
-
Labels:None
Description
JSON-RPC specs say that there should be an explicit null for error key:
{{
{ "result": "Hello JSON-RPC", "error": null, "id": 1}}}
However the error key is not set in ZF response:
{{
{ "result": "Hello JSON-RPC", "id": 1}}}
This has the effect of throwing exceptions on many client libraries, including the python package from json-rpc.org.
Result key should be set as null as well when response has errors.
Suggested modification:
public function toJson()
{
if ($this->isError()) {
$response = array(
'result' => null,
'error' => $this->getError()->toArray(),
'id' => $this->getId(),
);
} else {
$response = array(
'result' => $this->getResult(),
'id' => $this->getId(),
'error' => null
);
}
if (null !== ($version = $this->getVersion())) { $response['jsonrpc'] = $version; }
require_once 'Zend/Json.php';
return Zend_Json::encode($response);
}
any news on this one ?