本文整理汇总了PHP中Zend\Json\Json::decode方法的典型用法代码示例。如果您正苦于以下问题:PHP Json::decode方法的具体用法?PHP Json::decode怎么用?PHP Json::decode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Json\Json
的用法示例。
在下文中一共展示了Json::decode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: guardarAction
public function guardarAction()
{
$values = \Zend\Json\Json::decode($this->getRequest()->getContent());
$content = array();
foreach ($values as $key) {
$content[] = $key;
}
$nombre = $content[0];
$session = $content[1];
$messaggio = $content[2];
$color = 'yellow';
$xposition = rand(2, 1000);
$yposition = rand(3, 650);
$zposition = rand(1, 100);
$posiciones = $xposition . 'x' . $yposition . 'x' . $zposition;
$posterlab = $this->getSessioniDao()->tuttiPerId($session)->getPosterlab();
$tipo = 1;
$patron = 'Y-m-d H:i';
$fecha = new DateTime();
$fechactual = $fecha->format($patron);
$stato = 1;
$productos = array('nome' => $nombre, 'messaggio' => $messaggio, 'color' => $color, 'xyz' => $posiciones, 'posterlab_id' => $posterlab, 'tipo' => $tipo, 'sessione' => $session, 'data' => $fechactual, 'stato' => $stato);
$producto = new Interattivo();
$producto->exchangeArray($productos);
$nuevoid = $this->getInterattivoDao()->salvare($producto);
//$salvado = $this->getInterattivoDao()->salvare($producto);
if (!$nuevoid) {
$json = new JsonModel(array('data' => 'error'));
return $json;
} else {
$json = new JsonModel(array('data' => 'success', 'messaggio' => $messaggio));
return $json;
}
}
示例2: getResults
/**
* @return array
*/
public function getResults($offset, $itemCountPerPage)
{
$query = $this->createSearchQuery($offset, $itemCountPerPage);
$adapter = new Http\Client\Adapter\Curl();
$adapter->setOptions(array('curloptions' => array(CURLOPT_SSL_VERIFYPEER => false)));
$client = new Http\Client();
$client->setAdapter($adapter);
$client->setMethod('GET');
$client->setUri($this->getOptions()->getSearchEndpoint() . $query);
$response = $client->send();
if (!$response->isSuccess()) {
throw new Exception\RuntimeException("Invalid response received from CloudSearch.\n" . $response->getContent());
}
$results = Json::decode($response->getContent(), Json::TYPE_ARRAY);
$this->count = $results['hits']['found'];
if (0 == $this->count) {
return array();
}
if ($this->getOptions()->getReturnIdResults()) {
$results = $this->extractResultsToIdArray($results);
}
foreach ($this->getConverters() as $converter) {
$results = $converter->convert($results);
}
return $results;
}
示例3: fromString
/**
* Returns data from string
*
* @param string $string
* @return array
*/
public function fromString($string)
{
if (empty($string)) {
return array();
}
return \Zend\Json\Json::decode($string, \Zend\Json\Json::TYPE_ARRAY);
}
示例4: getPoolMedia
private function getPoolMedia($pool)
{
$director = $this->getServiceLocator()->get('director');
$result = $director->send_command("llist media pool=" . $pool, 2, null);
$media = \Zend\Json\Json::decode($result, \Zend\Json\Json::TYPE_ARRAY);
return $media['result']['volumes'];
}
示例5: getlistAction
/**
* Get a list of apprentices and mentors
*
* @return JsonModel
*/
public function getlistAction()
{
$config = $this->getServiceLocator()->get('config');
$file = $config['php.ug.mentoringapp']['file'];
$content = Json::decode(file_get_contents($file), Json::TYPE_ARRAY);
return new JsonModel($content);
}
示例6: getVolume
private function getVolume($volume)
{
$director = $this->getServiceLocator()->get('director');
$result = $director->send_command('llist volume="' . $volume . '"', 2, null);
$pools = \Zend\Json\Json::decode($result, \Zend\Json\Json::TYPE_ARRAY);
return $pools['result']['volume'];
}
示例7: getContactsFromResponse
protected function getContactsFromResponse()
{
if (!$this->response) {
return false;
}
$data = $this->response->getBody();
if (!$data) {
return false;
}
$data = Json::decode($data, 1);
if (!isset($data['feed']['entry'])) {
return false;
}
$users = $data['feed']['entry'];
foreach ($users as $key => $user) {
if (!isset($user['gd$email'])) {
continue;
}
$email = null;
foreach ($user['gd$email'] as $address) {
if ($email) {
continue;
}
$email = $address['address'];
}
if (!$email) {
continue;
}
$contacts[] = array('name' => isset($user['title']['$t']) ? $user['title']['$t'] : null, 'email' => $email);
}
return $contacts;
}
示例8: _parseParameters
protected function _parseParameters(HTTPResponse $response)
{
$params = array();
$body = $response->getBody();
if (empty($body)) {
return;
}
$tokenFormat = $this->getTokenFormat();
switch ($tokenFormat) {
case 'json':
$params = \Zend\Json\Json::decode($body);
break;
case 'jsonp':
break;
case 'pair':
$parts = explode('&', $body);
foreach ($parts as $kvpair) {
$pair = explode('=', $kvpair);
$params[rawurldecode($pair[0])] = rawurldecode($pair[1]);
}
break;
default:
throw new Exception\InvalidArgumentException(sprintf('Unable to handle access token response by undefined format %', $tokenFormat));
}
return (array) $params;
}
示例9: deleteAction
public function deleteAction()
{
foreach (Json::decode($this->getRequest()->getContent(), Json::TYPE_ARRAY) as $item) {
$this->service->deleteRow($item);
}
return new JsonModel([]);
}
示例10: getLatLng
public static function getLatLng($address)
{
$latLng = [];
try {
$url = sprintf('http://maps.google.com/maps/api/geocode/json?address=%s&sensor=false', $address);
$client = new Client($url);
$client->setAdapter(new Curl());
$client->setMethod('GET');
$client->setOptions(['curloptions' => [CURLOPT_HEADER => false]]);
$response = $client->send();
$body = $response->getBody();
$result = Json\Json::decode($body, 1);
$latLng = ['lat' => $result['results'][0]['geometry']['location']['lat'], 'lng' => $result['results'][0]['geometry']['location']['lng']];
$isException = false;
} catch (\Zend\Http\Exception\RuntimeException $e) {
$isException = true;
} catch (\Zend\Http\Client\Adapter\Exception\RuntimeException $e) {
$isException = true;
} catch (Json\Exception\RuntimeException $e) {
$isException = true;
} catch (Json\Exception\RecursionException $e2) {
$isException = true;
} catch (Json\Exception\InvalidArgumentException $e3) {
$isException = true;
} catch (Json\Exception\BadMethodCallException $e4) {
$isException = true;
}
if ($isException === true) {
//código em caso de problemas no decode
}
return $latLng;
}
示例11: loadSpecifications
/**
* Loads currencies specs
*/
private static function loadSpecifications()
{
if (!self::$specifications) {
$content = file_get_contents(__DIR__ . '/../data/currencies.json');
self::$specifications = Json::decode($content, Json::TYPE_ARRAY);
}
}
示例12: listOrdersAction
public function listOrdersAction()
{
$params = Json::decode($this->getRequest()->getContent(), Json::TYPE_ARRAY);
$order = $this->getServiceLocator()->get('TocatCore\\Model\\OrderTableGateway');
if (empty($params)) {
return new ViewModel(iterator_to_array($order->select()));
}
if (isset($params['ticket_id'])) {
$rowset = $order->select(function (Select $select) use($params) {
$select->join('order_ticket', 'order_ticket.order_uid = order.uid', array());
$select->join('ticket', 'order_ticket.ticket_uid = ticket.uid', array());
$select->where(array('ticket.ticket_id' => $params['ticket_id']));
$select->quantifier('DISTINCT');
});
return new ViewModel(iterator_to_array($rowset));
}
if (isset($params['project_id'])) {
$rowset = $order->select(function (Select $select) use($params) {
$select->join('order_project', 'order_project.order_uid = order.uid', array());
$select->join('project', 'order_project.project_uid = project.uid');
$select->where(array('project.project_id' => $params['project_id']));
$select->quantifier('DISTINCT');
});
return new ViewModel(iterator_to_array($rowset));
}
}
示例13: getFilesets
private function getFilesets()
{
$director = $this->getServiceLocator()->get('director');
$result = $director->send_command("list filesets", 2, null);
$filesets = \Zend\Json\Json::decode($result, \Zend\Json\Json::TYPE_ARRAY);
return $filesets['result']['filesets'];
}
示例14: getList
public function getList()
{
$config = $this->getServiceLocator()->get('config');
$file = $config['php.ug.event']['cachefile'];
$content = Json::decode(file_get_contents($file), Json::TYPE_ARRAY);
return new JsonModel($content);
}
示例15: setBudgetAction
public function setBudgetAction()
{
$params = Json::decode($this->getRequest()->getContent(), Json::TYPE_ARRAY);
switch ($params['type']) {
case 'project':
return new ApiProblemResponse(new ApiProblem(406, 'Not Implemented'));
break;
case 'ticket':
default:
$ticket = $this->getServiceLocator()->get('TocatCore\\Model\\TicketTableGateway');
$rowset = $ticket->select(array('ticket_id' => $params['id']));
if (count($rowset) < 1) {
return new ApiProblemResponse(new ApiProblem(404, 'Not Found'));
}
$order = $this->getServiceLocator()->get('TocatCore\\Model\\OrderTableGateway');
$orderList = $order->select(function (Select $select) use($rowset) {
$select->columns(array('totalBudget' => new Expression('SUM(order.budget)')));
$select->join('order_ticket', 'order_ticket.order_uid = order.uid', array());
$select->where(array('order_ticket.uid' => $rowset->current()->uid));
$select->group('order_ticket.uid');
});
if ($params['budget'] > $orderList->current()->totalBudget) {
return new ApiProblemResponse(new ApiProblem(406, 'Budget value bigger then total budget'));
}
$ticket->update(array('budget' => $params['budget']), array('uid' => $rowset->current()->uid));
$rowset = $ticket->select(array('ticket_id' => $params['id']));
return new ViewModel((array) $rowset->current() + (array) $orderList->current());
break;
}
}