本文整理汇总了PHP中Zend_Json_Decoder类的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Json_Decoder类的具体用法?PHP Zend_Json_Decoder怎么用?PHP Zend_Json_Decoder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Zend_Json_Decoder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: decode
/**
* Decodes the given $encodedValue string which is
* encoded in the JSON format
*
* Uses ext/json's json_decode if available.
*
* @param string $encodedValue Encoded in JSON format
* @param int $objectDecodeType Optional; flag indicating how to decode
* objects. See {@link Zend_Json_Decoder::decode()} for details.
* @return mixed
*/
public static function decode($encodedValue, $objectDecodeType = Zend_Json::TYPE_ARRAY)
{
$encodedValue = (string) $encodedValue;
if (function_exists('json_decode') && self::$useBuiltinEncoderDecoder !== true) {
$decode = json_decode($encodedValue, $objectDecodeType);
// php < 5.3
if (!function_exists('json_last_error')) {
if ($decode === $encodedValue) {
throw new Zend_Json_Exception('Decoding failed');
}
// php >= 5.3
} elseif (($jsonLastErr = json_last_error()) != JSON_ERROR_NONE) {
switch ($jsonLastErr) {
case JSON_ERROR_DEPTH:
throw new Zend_Json_Exception('Decoding failed: Maximum stack depth exceeded');
case JSON_ERROR_CTRL_CHAR:
throw new Zend_Json_Exception('Decoding failed: Unexpected control character found');
case JSON_ERROR_SYNTAX:
throw new Zend_Json_Exception('Decoding failed: Syntax error');
default:
throw new Zend_Json_Exception('Decoding failed');
}
}
return $decode;
}
return Zend_Json_Decoder::decode($encodedValue, $objectDecodeType);
}
示例2: _fetchPersonalInfo
public function _fetchPersonalInfo()
{
$faculty_id = $this->getFacultyId();
$cache = self::getCache('remote');
$facultyPersonal = $cache->load('facultyPersonal');
// see if a cache already exists:
if ($facultyPersonal === false or !isset($facultyPersonal[$faculty_id])) {
$PROTOCOL = 'http://';
$URL_STAFF_INFO = $PROTOCOL . CORE_SERVER . '/staff/getinfo' . "?staff_id={$faculty_id}";
$client = new Zend_Http_Client($URL_STAFF_INFO);
$client->setCookie('PHPSESSID', $_COOKIE['PHPSESSID']);
$response = $client->request();
if ($response->isError()) {
$remoteErr = 'REMOTE ERROR: (' . $response->getStatus() . ') ' . $response->getMessage();
Zend_Registry::get('logger')->err($remoteErr);
throw new Zend_Exception($remoteErr, Zend_Log::ERR);
} else {
$jsonContent = $response->getBody();
$facultyInfo = Zend_Json_Decoder::decode($jsonContent);
$facultyPersonal[$faculty_id] = $facultyInfo;
$cache->save($facultyPersonal, 'facultyPersonal');
}
}
return $facultyPersonal[$faculty_id];
}
示例3: _unmapCustom
/**
* @return AM_Mapper_Sqlite_Element
*/
protected function _unmapCustom()
{
$sContentText = null;
$oElementDataSet = $this->getModel()->getResources();
/* @var $oElementDataSet AM_Model_Db_Element_Data_Abstract */
foreach ($oElementDataSet->getData() as $oElementData) {
/* @var $oElementData AM_Model_Db_Element_Data_Abstract */
if (AM_Model_Db_Element_Data_Resource::PDF_INFO == $oElementData->key_name) {
if (!empty($oElementData->value)) {
$aPdfInfo = Zend_Json_Decoder::decode($oElementData->value, true);
$sContentText = $aPdfInfo['text'];
}
}
$sElementDataMapperClassName = self::ELEMENT_DATA_MAPPER_CLASS_PREFIX . Zend_Filter::filterStatic($oElementData->key_name, 'Word_UnderscoreToCamelCase');
if (class_exists($sElementDataMapperClassName, true)) {
$oElementDataMapper = new $sElementDataMapperClassName($oElementData, array('adapter' => $this->_getAdapter()));
$oElementDataMapper->unmap();
continue;
}
$aData = array('element_id' => $this->getModel()->id, 'type' => $oElementData->key_name, 'value' => $oElementDataSet->getDataValueForExport($oElementData->key_name), 'position_id' => 0);
$this->_getSqliteGateway('element_data')->insert($aData);
}
$aData = array('id' => $this->getModel()->id, 'page_id' => $this->getModel()->page, 'element_type_name' => $this->getModel()->getFieldTypeTitle(), 'weight' => intval($this->getModel()->weight), 'content_text' => $sContentText);
$this->_getSqliteGateway()->insert($aData);
return $this;
}
示例4: testPoolsNoMonetaryUserAction
public function testPoolsNoMonetaryUserAction()
{
$this->loginByUserId(App_Test_PHPUnit_Framework_TestCase::PROVIDER_NO_MONETARY_USER_ID);
$this->get(self::NS . '/pools', array('id' => 234));
$body = $this->getResponse()->getBody();
$pool = Zend_Json_Decoder::decode($body);
$this->assertNotEmpty($pool);
$this->assertNotEmpty($pool['data']);
$this->assertEmpty(@$pool['totalExpense']);
$this->assertEmpty(@$pool['dataExpense']);
$this->assertEmpty(@$pool['smsExpense']);
$this->assertEmpty(@$pool['voiceExpense']);
$this->assertEmpty(@$pool['expenseTimestamp']);
$pool = $pool['data'];
$pools = array('dataPools', 'smsPools', 'voiceOriginatedPools', 'voiceTerminatedPools');
foreach ($pools as $poolInformation) {
$this->assertNotEmpty($pool[$poolInformation]);
$poolInformation = current($pool[$poolInformation]);
$this->assertNotEmpty($poolInformation['zoneGroupId']);
$this->assertNotEmpty($poolInformation['zoneGroupName']);
$this->assertNotEmpty($poolInformation['consumption']);
$this->assertEmpty(@$poolInformation['expense']);
$this->assertEmpty(@$poolInformation['q1Absolute']);
}
$this->assertNotEmpty($pool['lastPoolTimestamp']);
$this->assertResponseCode("200");
}
示例5: viewemailidsAction
public function viewemailidsAction()
{
$this->_helper->viewRenderer->setNoRender(true);
$this->_helper->layout()->disableLayout();
$member_ids = array(1, 2, 3, 4, 5);
$httpClient = new Zend_Http_Client('http://' . CORE_SERVER . '/student/fetchemailids');
//$httpClient->setCookie('PHPSESSID', $_COOKIE['PHPSESSID']);
$httpClient->setMethod('POST');
$call_back = 'viewbatchinfo';
$httpClient->setParameterPost(array('member_ids' => $member_ids, 'format' => 'json', 'call_back' => $call_back));
$response = $httpClient->request();
if ($response->isError()) {
$remoteErr = 'REMOTE ERROR: (' . $response->getStatus() . ') ' . $response->getHeader('Message') . $response->getBody();
throw new Zend_Exception($remoteErr, Zend_Log::ERR);
} else {
$jsonContent = $response->getBody($response);
Zend_Registry::get('logger')->debug($jsonContent);
Zend_Registry::get('logger')->debug(Zend_Json_Decoder::decode($jsonContent));
Zend_Registry::get('logger')->debug(json_decode($jsonContent));
/*Zend_Registry::get('logger')->debug(
Zend_Json_Decoder::decode($jsonContent));*/
/*$r = Zend_Json_Decoder::decode($jsonContent);
$batch_info = $r['batch_info'];
Zend_Registry::get('logger')->debug($batch_info);*/
}
}
示例6: __construct
/**
* Constructeur de la classe
*
* @access public
* @author Mathieu Desvé, <mathieu.desve@unflux.fr>
* @param array|object|Zend_Db_Table_Row_Abstract|string vo Object permettant de remplire l'instance
* @return mixed
*/
public function __construct($vo = array())
{
if ($vo instanceof Zend_Db_Table_Row_Abstract) {
$vo = $vo->toArray();
}
if (is_string($vo) && preg_match('/^\\{("(\\.|[^"\\\\n\\r])*?"|[,:{}\\[\\]0-9.\\-+Eaeflnr-u \\n\\r\\t])+?\\}$/', $vo)) {
$vo = Zend_Json_Decoder::decode($vo, Zend_Json::TYPE_ARRAY);
}
if (is_array($vo)) {
foreach ($vo as $key => $value) {
$key = $this->_getKey($key);
if ($key) {
$this->{$key} = $value;
}
}
} elseif (is_object($vo)) {
foreach ($vo as $key => $value) {
$key = $this->_getKey($key);
if ($key) {
$this->{$key} = $value;
}
}
} else {
throw new Vo_Exception('Invalide type of comment parameter in contructor.', 3);
}
}
示例7: call
/**
* Call path (with optional parameters) on base url using the given method.
*
* @throws Zend_Http_Client_Exception
* @param $path URL path
* @param string $method POST|GET|PUT|DELETE
* @param bool|array $args Optional parameters for PUT/POST requests
* @return mixed
*/
public function call($path, $method = 'GET', $args = false, $verbose = false)
{
$client = $this->getClient();
$client->setUri($this->_getClientUrl() . $path);
if ($verbose) {
echo "### URL: " . $this->_getClientUrl() . $path . "\n";
}
if ($args && ($method == 'POST' || $method == 'PUT')) {
foreach ($args as $k => $v) {
$client->setParameterPost($k, $v);
}
} else {
if ($args && $method == 'GET') {
foreach ($args as $k => $v) {
$client->setParameterGet($k, $v);
}
}
}
try {
$result = $client->request($method);
if ($verbose) {
echo "###Result:\n";
var_dump($result->getBody());
echo "###\n\n";
}
if (!$result->isSuccessful()) {
throw new Exception('API request failed miserably', $result->getStatus());
}
return Zend_Json_Decoder::decode($result->getBody());
} catch (Zend_Http_Client_Exception $e) {
throw $e;
}
}
示例8: decode
/**
* Decodes the given $encodedValue string which is
* encoded in the JSON format
*
* Uses ext/json's json_decode if available.
*
* @param string $encodedValue Encoded in JSON format
* @param int $objectDecodeType Optional; flag indicating how to decode
* objects. See {@link ZJsonDecoder::decode()} for details.
* @return mixed
*/
public static function decode($encodedValue, $objectDecodeType = Zend_Json::TYPE_ARRAY)
{
if (function_exists('json_decode') && self::$useBuiltinEncoderDecoder !== true) {
return json_decode($encodedValue, $objectDecodeType);
}
import('lib.Json.Decoder');
return Zend_Json_Decoder::decode($encodedValue, $objectDecodeType);
}
示例9: decode
/**
* Decodes the given $encodedValue string which is
* encoded in the JSON format
*
* Uses ext/json's json_decode if available.
*
* @param string $encodedValue Encoded in JSON format
* @param int $objectDecodeType Optional; flag indicating how to decode
* objects. See {@link ZJsonDecoder::decode()} for details.
* @return mixed
*/
public static function decode($encodedValue, $objectDecodeType = Zend_Json::TYPE_ARRAY)
{
if (function_exists('json_decode')) {
return json_decode($encodedValue, $objectDecodeType);
}
include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Json' . DIRECTORY_SEPARATOR . 'Decoder.php';
return Zend_Json_Decoder::decode($encodedValue, $objectDecodeType);
}
示例10: decode
/**
* Decodes the given $encodedValue string which is
* encoded in the JSON format
*
* Uses ext/json's json_decode if available.
*
* @param string $encodedValue Encoded in JSON format
* @param int $objectDecodeType Optional; flag indicating how to decode
* objects. See {@link ZJsonDecoder::decode()} for details.
* @return mixed
*/
public static function decode($encodedValue, $objectDecodeType = Zend_Json::TYPE_ARRAY)
{
if (function_exists('json_decode')) {
return json_decode($encodedValue, $objectDecodeType);
}
include_once 'Zend/Json/Decoder.php';
return Zend_Json_Decoder::decode($encodedValue, $objectDecodeType);
}
示例11: decode
/**
* Decodes the given $encodedValue string which is
* encoded in the JSON format
*
* Uses ext/json's json_decode if available.
*
* @param string $encodedValue Encoded in JSON format
* @param int $objectDecodeType Optional; flag indicating how to decode
* objects. See {@link Zend_Json_Decoder::decode()} for details.
* @return mixed
*/
public static function decode($encodedValue, $objectDecodeType = Zend_Json::TYPE_ARRAY)
{
if (function_exists('json_decode') && self::$useBuiltinEncoderDecoder !== true) {
return json_decode($encodedValue, $objectDecodeType);
}
require_once 'Zend/Json/Decoder.php';
return Zend_Json_Decoder::decode($encodedValue, $objectDecodeType);
}
示例12: testGetVpns
public function testGetVpns()
{
$this->loginByUserId(\App_Test_PHPUnit_Framework_TestCase::CUSTOMER_API_ID, $this->_authType);
$this->get($this->_controllerUrl . '/' . $this->_customerId . '/' . 'vpns', $this->_queryParams);
$response = $this->getResponse()->getBody();
$vpns = Zend_Json_Decoder::decode($response);
$this->assertEquals(array($this->vpns), $vpns['data']);
}
示例13: _getElevationApiCall
/** Get the coordinates from an address string
* @access public
* @param float $lat
* @param float $lon
* @access public
*/
public function _getElevationApiCall($lat, $lon)
{
$client = new Zend_Http_Client();
$client->setUri(self::ELEVATIONURI);
$client->setParameterGet('locations', (string) $lon . ',' . (string) $lat)->setParameterGet('sensor', 'false');
$result = $client->request('GET');
$response = Zend_Json_Decoder::decode($result->getBody(), Zend_Json::TYPE_OBJECT);
return $response;
}
示例14: save
public function save($data)
{
$this->_tableMailing->insert($data);
$idMailing = $this->_tableMailing->getAdapter()->lastInsertId();
if ($data['template'] == 'contactBusinessman') {
$data = Zend_Json_Decoder::decode($data['data']);
$this->_tableMailing->getAdapter()->insert($this->_nameTableBusinessman, array('idmailing' => $idMailing, 'codempr' => $data['codempr']));
}
}
示例15: update_method
function update_method()
{
$json = trim($_REQUEST['json']);
require_once MongoAdmin::$root_path . '/deps/zend_json_decoder.php';
$vars = Zend_Json_Decoder::decode($json, Zend_Json_Decoder::TYPE_ARRAY);
$coll = MongoAdmin::db()->selectCollection($_REQUEST['coll']);
$coll->update(array('_id' => $_REQUEST['doc']), $vars);
redirect(url('doc.edit', array('coll' => $coll->getName(), 'doc' => $_REQUEST['doc'])));
}