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


PHP Zend_Json::prettyPrint方法代码示例

本文整理汇总了PHP中Zend_Json::prettyPrint方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Json::prettyPrint方法的具体用法?PHP Zend_Json::prettyPrint怎么用?PHP Zend_Json::prettyPrint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Json的用法示例。


在下文中一共展示了Zend_Json::prettyPrint方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getRecursiveAsJson

 /**
  * @param string $directory 
  * @param boolean $prettyPrint
  */
 public static function getRecursiveAsJson($directory, $prettyPrint = false)
 {
     $json = \Zend_Json::encode(self::getRecursive($directory));
     if ($prettyPrint) {
         return \Zend_Json::prettyPrint($json, array("indent" => "  "));
     }
     return $json;
 }
开发者ID:rukzuk,项目名称:rukzuk,代码行数:12,代码来源:Helper.php

示例2: json

 public static function json($data, $format = 'plain')
 {
     if ($format == 'pretty') {
         $message = Zend_Json::encode($data);
         return Zend_Json::prettyPrint($message, array("format" => "html"));
     } else {
         return Zend_Json::encode($data);
     }
 }
开发者ID:dadigo,项目名称:simpleinvoices,代码行数:9,代码来源:encode.php

示例3: __toString

 public function __toString()
 {
     $str = parent::__toString();
     if ($this->_entity) {
         $str .= "\nEntity: " . $this->_entity;
     }
     if (!empty($this->_validationErrors)) {
         $str .= "\nValidation errors:\n" . \Zend_Json::prettyPrint(\Zend_Json::encode($this->_validationErrors), array("indent" => "  "));
     }
     return $str;
 }
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:11,代码来源:ValidateException.php

示例4: deleteAction

 public function deleteAction()
 {
     $this->_helper->viewRenderer->setNoRender();
     if ($this->_request->isPost()) {
         $paramId = $this->getParam('id');
         $mdlPages = new Model_Admin($paramId);
         $deletePage = $mdlPages->deletePage();
         $json = Zend_Json::encode($deletePage);
         echo Zend_Json::prettyPrint($json);
         die;
     }
 }
开发者ID:p-artem,项目名称:zend.site,代码行数:12,代码来源:AdminController.php

示例5: uploadException

 /**
  * @param \Exception $e
  */
 public function uploadException(\Exception $e)
 {
     $arrE = (array) $e;
     $previous = array();
     while (method_exists($e, 'getPrevious') && $e->getPrevious() && ($e = $e->getPrevious())) {
         $previous[] = array("message" => $e->getMessage(), "trace" => $e->getTraceAsString());
     }
     while (!method_exists($e, 'getPrevious') && $e->_previous && ($e = $e->_previous)) {
         $previous[] = array("message" => $e->getMessage(), "trace" => $e->getTraceAsString());
     }
     $arrE = $this->objectToArray($arrE, 3);
     $arrE["previous"] = $previous;
     $serialized = \Zend_Json::prettyPrint(\Zend_Json::encode($arrE));
     return $this->_debugLogUploader->uploadString('exception', $serialized, 'text/plain');
 }
开发者ID:JaroslavRamba,项目名称:ex-facebook-bundle,代码行数:18,代码来源:Log.php

示例6: find

 function find($id)
 {
     $info = array();
     if ($this->rech_db) {
         $info = $this->find_db($id);
     } else {
         $info = $this->find_salesforce($id);
     }
     if (isset($info['UnitPrice'])) {
         /* Formatage de prix */
         $prix = $info['UnitPrice'];
         $info['UnitPrice'] = $this->montant($prix);
         $info['UnitPrice_ttc'] = $this->montant_ttc($prix);
     }
     $info['pdf'] = Zend_Json::prettyPrint(Zend_Json::encode($info));
     return $info;
 }
开发者ID:r1zib,项目名称:salesforce,代码行数:17,代码来源:Products.php

示例7: render

 /**
  * Render a Zend_Config into a JSON config string.
  *
  * @since 1.10
  * @return string
  */
 public function render()
 {
     $data = $this->_config->toArray();
     $sectionName = $this->_config->getSectionName();
     $extends = $this->_config->getExtends();
     if (is_string($sectionName)) {
         $data = array($sectionName => $data);
     }
     foreach ($extends as $section => $parent_section) {
         $data[$section][ZendL_Config_Json::EXTENDS_NAME] = $parent_section;
     }
     $out = Zend_Json::encode($data);
     if ($this->_prettyPrint) {
         $out = Zend_Json::prettyPrint($out);
     }
     return $out;
 }
开发者ID:jtietema,项目名称:Fizzy,代码行数:23,代码来源:Json.php

示例8: postDispatch

 public function postDispatch()
 {
     $data = $this->View()->getAssign();
     $pretty = $this->Request()->getParam('pretty', false);
     array_walk_recursive($data, function (&$value) {
         // Convert DateTime instances to ISO-8601 Strings
         if ($value instanceof DateTime) {
             $value = $value->format(DateTime::ISO8601);
         }
     });
     $data = Zend_Json::encode($data);
     if ($pretty) {
         $data = Zend_Json::prettyPrint($data);
     }
     $this->response()->setHeader('Content-type', 'application/json', true);
     $this->response()->setBody($data);
 }
开发者ID:ClaudioThomas,项目名称:shopware-4,代码行数:17,代码来源:Rest.php

示例9: _toHtml

 public function _toHtml()
 {
     $output = '<table>';
     foreach ($this->log->_data as $key => $value) {
         if ($this->isJson($value)) {
             $value = '<pre>' . Zend_Json::prettyPrint($value) . '</pre>';
         } elseif ($this->isSerializedArray($value)) {
             $value_lines = unserialize($value);
             $value_output = '';
             foreach ($value_lines as $key => $line) {
                 $value_output .= sprintf('<tr><td>%s</td><td>%s</td></tr>', $key, $line);
             }
             $value = '<table>' . $value_output . '</table>';
         } else {
             $value = '<pre>' . $value . '</pre>';
         }
         $output .= sprintf('<tr><th>%s</th><td>%s</td></tr>', $key, $value);
     }
     $output .= '</table>';
     echo $output;
 }
开发者ID:netresearch,项目名称:Magento-Logmon,代码行数:21,代码来源:View.php

示例10: direct

 /**
  * Prepare the JSON, send it, and exit the application.
  * 
  * @param mixed $data
  */
 public function direct($data)
 {
     $response = $this->getResponse();
     $request = $this->getRequest();
     $response->setHeader('Content-Type', 'application/json', true);
     // Add header data for JSONP requests.
     if (isset($_GET['callback'])) {
         $response->setHeader('Content-Type', 'application/javascript', true);
         $headers = array('status' => $response->getHttpResponseCode());
         $data = array('headers' => $headers, 'data' => $data);
     }
     $json = Zend_Json::encode($data);
     // Pretty print the JSON if requested.
     if (isset($_GET['pretty_print'])) {
         $json = Zend_Json::prettyPrint($json);
     }
     // Wrap the JSON with a callback function if requested.
     if (isset($_GET['callback'])) {
         $json = $_GET['callback'] . "({$json});";
     }
     $response->setBody($json);
     $response->sendResponse();
     exit;
 }
开发者ID:lchen01,项目名称:STEdwards,代码行数:29,代码来源:JsonApi.php

示例11: testJsonPrettyPrintWorksWithHtmlOutputFormat

 /**
  * @group ZF-9577
  */
 public function testJsonPrettyPrintWorksWithHtmlOutputFormat()
 {
     $o = new stdClass();
     $o->four = 4;
     $o->foo = array(1, 2, 3);
     $jsonstr = Zend_Json::encode($o);
     $targetHtmlOutput = '{<br />&nbsp;&nbsp;&nbsp;&nbsp;"four":4,<br />&nbsp;&nbsp;&nbsp;&nbsp;"foo":[<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3<br />&nbsp;&nbsp;&nbsp;&nbsp;]<br />}';
     $this->assertEquals($targetHtmlOutput, Zend_Json::prettyPrint($jsonstr, array('format' => 'html')));
 }
开发者ID:jsnshrmn,项目名称:Suma,代码行数:12,代码来源:JsonTest.php

示例12: mkdir

<?php

\Pimcore\Cache::disable();
$customCacheFile = PIMCORE_CONFIGURATION_DIRECTORY . "/cache.xml";
// create legacy config folder
$legacyFolder = PIMCORE_CONFIGURATION_DIRECTORY . "/LEGACY";
if (!is_dir($legacyFolder)) {
    mkdir($legacyFolder, 0777, true);
}
if (file_exists($customCacheFile)) {
    try {
        $conf = new \Zend_Config_Xml($customCacheFile);
        $arrayConf = $conf->toArray();
        $content = json_encode($arrayConf);
        $content = \Zend_Json::prettyPrint($content);
        $jsonFile = \Pimcore\Config::locateConfigFile("cache.json");
        file_put_contents($jsonFile, $content);
        rename($customCacheFile, $legacyFolder . "/cache.xml");
    } catch (\Exception $e) {
    }
}
开发者ID:SeerUK,项目名称:pimcore-manual-updater,代码行数:21,代码来源:postupdate.php

示例13: foreach

// layouts
$classType = 'Block';
$layouts = $utilityFiles->getLayoutFiles([], false);
foreach ($layouts as $file) {
    $xml = simplexml_load_file($file);
    $classes = \Magento\Framework\App\Utility\Classes::collectLayoutClasses($xml);
    $factoryNames = array_filter($classes, 'isFactoryName');
    if (!$factoryNames) {
        continue;
    }
    foreach ($factoryNames as $factoryName) {
        list($module, $name) = getModuleName($factoryName, $compositeModules);
        $map[$classType][$factoryName] = getClassName($module, $classType, $name);
    }
}
echo Zend_Json::prettyPrint(Zend_Json::encode($map));
/**
 * Get combined array from similar files by pattern
 *
 * @param string $dirPath
 * @param string $filePattern
 * @return array
 */
function getFilesCombinedArray($dirPath, $filePattern)
{
    $result = [];
    $directoryIterator = new DirectoryIterator($dirPath);
    $patternIterator = new RegexIterator($directoryIterator, $filePattern);
    foreach ($patternIterator as $fileInfo) {
        $arrayFromFile = (include_once $fileInfo->getPathname());
        $result = array_merge($result, $arrayFromFile);
开发者ID:shabbirvividads,项目名称:magento2,代码行数:31,代码来源:get_aliases_map.php

示例14: render

 /**
  * Render a Zend_Config into a JSON config string.
  *
  * @since 1.10
  * @return string
  */
 public function render()
 {
     $data = $this->_config->toArray();
     $sectionName = $this->_config->getSectionName();
     $extends = $this->_config->getExtends();
     if (is_string($sectionName)) {
         $data = array($sectionName => $data);
     }
     foreach ($extends as $section => $parentSection) {
         $data[$section][Zend_Config_Json::EXTENDS_NAME] = $parentSection;
     }
     // Ensure that each "extends" section actually exists
     foreach ($data as $section => $sectionData) {
         if (is_array($sectionData) && isset($sectionData[Zend_Config_Json::EXTENDS_NAME])) {
             $sectionExtends = $sectionData[Zend_Config_Json::EXTENDS_NAME];
             if (!isset($data[$sectionExtends])) {
                 // Remove "extends" declaration if section does not exist
                 unset($data[$section][Zend_Config_Json::EXTENDS_NAME]);
             }
         }
     }
     $out = Zend_Json::encode($data);
     if ($this->prettyPrint()) {
         $out = Zend_Json::prettyPrint($out);
     }
     return $out;
 }
开发者ID:kobmaki,项目名称:icingaweb2,代码行数:33,代码来源:Json.php

示例15: exportCustomLayoutDefinitionAction

 public function exportCustomLayoutDefinitionAction()
 {
     $this->removeViewRenderer();
     $id = intval($this->getParam("id"));
     if ($id) {
         $customLayout = Object\ClassDefinition\CustomLayout::getById($id);
         if ($customLayout) {
             $name = $customLayout->getName();
             unset($customLayout->id);
             unset($customLayout->classId);
             unset($customLayout->name);
             unset($customLayout->creationDate);
             unset($customLayout->modificationDate);
             unset($customLayout->userOwner);
             unset($customLayout->userModification);
             unset($customLayout->fieldDefinitions);
             header("Content-type: application/json");
             header("Content-Disposition: attachment; filename=\"custom_definition_" . $name . "_export.json\"");
             $json = json_encode($customLayout);
             $json = \Zend_Json::prettyPrint($json);
             echo $json;
             die;
         }
     }
     $errorMessage = ": Custom Layout with id [ " . $id . " not found. ]";
     Logger::error($errorMessage);
     echo $errorMessage;
 }
开发者ID:pimcore,项目名称:pimcore,代码行数:28,代码来源:ClassController.php


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