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


PHP Json::encode方法代码示例

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


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

示例1: testComplex

 public function testComplex()
 {
     $data = ['a' => 1, 'b' => [1, 2, 4], 'c' => 3, 'd' => 4, 'e' => 5];
     $json = Json::encode($data);
     $map = Json::toMap($json);
     $this->assertTrue($map instanceof Map);
     $this->assertTrue($map->get('b') instanceof ArrayList);
     $this->assertEquals($data, $map->toArray());
 }
开发者ID:phootwork,项目名称:json,代码行数:9,代码来源:CollectionTest.php

示例2: updateExtensions

 protected function updateExtensions(Package &$model, KeekoPackageSchema $pkg)
 {
     // remove all existing extensions from this package first
     ExtensionQuery::create()->filterByPackage($model)->delete();
     // add them one by one
     foreach ($pkg->getAllExtensions() as $key => $exts) {
         foreach ($exts as $data) {
             $ext = new Extension();
             $ext->setKey($key);
             $ext->setData(Json::encode($data, Json::UNESCAPED_SLASHES));
             $ext->setPackage($model);
             $ext->save();
         }
     }
 }
开发者ID:keeko,项目名称:framework,代码行数:15,代码来源:AbstractPackageInstaller.php

示例3: run

 /**
  * Automatically generated run method
  *
  * @param Request $request
  * @return Response
  */
 public function run(Request $request)
 {
     $url = str_replace($request->getRequestUri(), '', $request->getUri());
     $baseurl = str_replace($url, '', $this->getBaseUrl());
     $sport = SportQuery::create()->findOneById($this->getParam('sport'));
     if (!$sport->getIsDefault()) {
         $baseurl .= '/' . $sport->getSlug();
     }
     // load assets
     $page = $this->getServiceContainer()->getKernel()->getApplication()->getPage();
     $repo = $this->getServiceContainer()->getResourceRepository();
     $page->addStyles($repo->find('/gossi/trixionary-client/public/app/assets/*.css')->getPaths());
     $page->addScripts($repo->find('/gossi/trixionary-client/public/app/assets/vendor-*.js')->getPaths());
     $page->addScripts($repo->find('/gossi/trixionary-client/public/app/assets/trixionary-*.js')->getPaths());
     // set configuration
     $prefs = $this->getServiceContainer()->getPreferenceLoader()->getSystemPreferences();
     $config = ['modulePrefix' => 'trixionary', 'environment' => 'production', 'rootURL' => $baseurl, 'locationType' => 'auto', 'APP' => ['name' => 'trixionary', 'version' => '0.0.0+0d11dfba'], 'keeko' => ['api' => $prefs->getApiUrl(), 'trixionary' => ['sportId' => $sport->getId(), 'slug' => ['skill' => $sport->getSkillSlug(), 'group' => $sport->getGroupSlug(), 'object' => $sport->getObjectSlug()]]]];
     $meta = new Meta();
     $meta->setName('trixionary/config/environment');
     $meta->setContent(rawurlencode(Json::encode($config)));
     $page->addMeta($meta);
     return $this->responder->run($request, new Blank(['sport' => $sport]));
 }
开发者ID:gossi,项目名称:trixionary-client,代码行数:29,代码来源:SportAction.php

示例4: testExtendedPackage

 public function testExtendedPackage()
 {
     $package = PackageSchema::fromFile(__DIR__ . '/fixture/extended.json');
     $json = Json::encode($package->toArray(), Json::PRETTY_PRINT | Json::UNESCAPED_SLASHES);
     $expected = file_get_contents(__DIR__ . '/fixture/extended.json');
     $this->assertEquals($expected, $json);
 }
开发者ID:keeko,项目名称:framework,代码行数:7,代码来源:ComposerSchemaTest.php

示例5: testEncodeBroken

 /**
  * @expectedException \phootwork\json\JsonException
  * @expectedExceptionCode \phootwork\json\Json::ERROR_UTF8
  */
 public function testEncodeBroken()
 {
     Json::encode([pack("H*", 'c32e')]);
 }
开发者ID:phootwork,项目名称:json,代码行数:8,代码来源:JsonTest.php


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