private function thunkMongoId($id) { if ($id instanceof MongoId) { return $id; } if ($id[0] == '~') { return Genghis_Json::decode(base64_decode(substr($id, 1))); } return preg_match('/^[a-f0-9]{24}$/i', $id) ? new MongoId($id) : $id; }
public function renderContent() { print Genghis_Json::encode($this->data); }
protected function getRequestData($gfj = true) { $data = file_get_contents('php://input'); if ($gfj) { try { $json = Genghis_Json::decode($data); } catch (Genghis_JsonException $e) { throw new Genghis_HttpException(400, 'Malformed document'); } } else { $json = json_decode($data, true); } if (empty($json)) { throw new Genghis_HttpException(400, 'Malformed document'); } return $json; }
protected function decodeJson($data, $gfj = true) { if ($gfj) { try { return Genghis_Json::decode($data); } catch (Genghis_JsonException $e) { throw new Genghis_HttpException(400, 'Malformed document'); } } else { $json = json_decode($data, true); if ($json === false && trim($data) != '') { throw new Genghis_HttpException(400, 'Malformed document'); } return $json; } }