当前位置: 首页>>代码示例>>PHP>>正文


PHP Json::decode方法代码示例

本文整理汇总了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;
     }
 }
开发者ID:sebaxplace,项目名称:skilla-local,代码行数:34,代码来源:IndexController.php

示例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;
 }
开发者ID:outeredge,项目名称:edge-zf2,代码行数:29,代码来源:CloudSearchSearcher.php

示例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);
 }
开发者ID:neeckeloo,项目名称:AmChartsPHP,代码行数:13,代码来源:Json.php

示例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'];
 }
开发者ID:neverstoplwy,项目名称:bareos-webui,代码行数:7,代码来源:PoolController.php

示例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);
 }
开发者ID:tsilvers,项目名称:php.ug,代码行数:12,代码来源:MentoringAppController.php

示例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'];
 }
开发者ID:neverstoplwy,项目名称:bareos-webui,代码行数:7,代码来源:MediaController.php

示例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;
 }
开发者ID:ahyswang,项目名称:eva-engine,代码行数:32,代码来源:Google.php

示例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;
 }
开发者ID:ahyswang,项目名称:eva-engine,代码行数:26,代码来源:AbstractToken.php

示例9: deleteAction

 public function deleteAction()
 {
     foreach (Json::decode($this->getRequest()->getContent(), Json::TYPE_ARRAY) as $item) {
         $this->service->deleteRow($item);
     }
     return new JsonModel([]);
 }
开发者ID:opsway,项目名称:tocat-opsdesk-platform,代码行数:7,代码来源:GroupController.php

示例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;
 }
开发者ID:armenio,项目名称:armenio-zf2-geolocation-module,代码行数:32,代码来源:GeoLocation.php

示例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);
     }
 }
开发者ID:coolms,项目名称:money,代码行数:10,代码来源:Currencies.php

示例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));
     }
 }
开发者ID:opsway,项目名称:tocat-opsdesk-platform,代码行数:26,代码来源:ListOrdersController.php

示例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'];
 }
开发者ID:syllaibr64,项目名称:bareos-webui,代码行数:7,代码来源:FilesetController.php

示例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);
 }
开发者ID:krsreenatha,项目名称:php.ug,代码行数:7,代码来源:EventController.php

示例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;
     }
 }
开发者ID:opsway,项目名称:tocat-opsdesk-platform,代码行数:30,代码来源:SetBudgetController.php


注:本文中的Zend\Json\Json::decode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。