/** * Encode input $array to JSON * * @param array $array * @throws Exception */ private function toJSON($array) { /* * JSON-P case */ $pretty = isset($this->context->query['_pretty']) ? filter_var($this->context->query['_pretty'], FILTER_VALIDATE_BOOLEAN) : false; if (isset($this->context->query['callback'])) { return $this->context->query['callback'] . '(' . json_encode($array, $pretty) . ')'; } return RestoUtil::json_format($array, $pretty); }
/** * Output product description as a GeoJSON Feature * * @param boolean $pretty : true to return pretty print */ public function toJSON($pretty = false) { return RestoUtil::json_format($this->toArray(true), $pretty); }
/** * Output collections descriptions as a JSON stream * * @param boolean $pretty : true to return pretty print */ public function toJSON($pretty) { $collections = array('synthesis' => array('name' => '*', 'osDescription' => isset($this->context->osDescription[$this->context->dictionary->language]) ? $this->context->osDescription[$this->context->dictionary->language] : $this->context->osDescription['en'], 'statistics' => $this->context->dbDriver->get(RestoDatabaseDriver::STATISTICS, array('collectionName' => null, 'facetFields' => $this->model->getFacetFields()))), 'collections' => array()); foreach (array_keys($this->collections) as $key) { $collections['collections'][] = $this->collections[$key]->toArray(true); } return RestoUtil::json_format($collections, $pretty); }
/** * Return the cart as a JSON file * * @param boolean $pretty */ public function toJSON($pretty) { $informations = $this->generateItemsInformations(); return RestoUtil::json_format(array('status' => 'success', 'message' => 'Order ' . $this->order['orderId'] . ' for user ' . $this->user->profile['email'], 'order' => array('orderId' => $this->order['orderId'], 'items' => $informations['items'], 'errors' => $informations['errors'])), $pretty); }
/** * Return the cart as a JSON file * * @param boolean $pretty */ public function toJSON($pretty) { return RestoUtil::json_format($this->getItems(), $pretty); }