Index: json.php =================================================================== --- json.php (revision 10242) +++ json.php (working copy) @@ -7,30 +7,25 @@ } public function setHeader() { - $this->response->setContentType('text/plain'); + $this->response->setContentType('text/x-json'); $this->response->setCharset('utf-8'); } - - public function dispatch($xmldom, $exceptions = null) { - //if ($this->state != API_STATE_READY) { - // $this->prepare(); - //} - - if ($xmldom instanceof DOMDocument) { + public function dispatch($data, $exceptions = null) { + if (is_string($data)) { + echo $data; + } elseif (is_array($data) || is_object($data)) { + $data = Zend_Json::encode($data); + } elseif ($data instanceof DOMDocument) { $this->setHeader(); - $xpath = new DOMXPath($xmldom); + $xpath = new DOMXPath($data); $this->response->send(); $query = '/'; - $blah = api_helpers_json::xmlStringToJson($xmldom->saveXML()); - - print $blah; - - + $json = api_helpers_json::xmlStringToJson($data->saveXML()); + echo $json; } else { throw new api_exception_queryserver(array()); return; } } } -