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


PHP Json::decode方法代码示例

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


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

示例1: __construct

 public function __construct()
 {
     $this->extensions = new Map();
     $this->packages = new Map();
     // load up all extensions
     $exts = ExtensionQuery::create()->joinPackage()->find();
     foreach ($exts as $ext) {
         /* @var $ext Extension */
         $key = $ext->getKey();
         $packageName = $ext->getPackage()->getName();
         $data = Json::decode($ext->getData());
         // add to global extensions
         if (!$this->extensions->has($key)) {
             $this->extensions->set($key, new ArrayList());
         }
         $this->extensions->get($key)->add($data);
         // add to package extensions
         if (!$this->packages->has($packageName)) {
             $this->packages->set($packageName, new Map());
         }
         $pkg = $this->packages->get($packageName);
         if (!$pkg->has($key)) {
             $pkg->set($key, new ArrayList());
         }
         $pkg->get($key)->add($data);
     }
 }
开发者ID:keeko,项目名称:framework,代码行数:27,代码来源:ExtensionRegistry.php

示例2: load

 /**
  * {@inheritDoc}
  * @see \Symfony\Component\Translation\Loader\LoaderInterface::load()
  */
 public function load($resource, $locale, $domain = 'messages')
 {
     $repo = $this->service->getResourceRepository();
     if (!$repo->contains($resource)) {
         throw new NotFoundResourceException(sprintf('File "%s" not found.', $resource));
     }
     // find file in puli repo
     $file = $repo->get($resource);
     $json = $file->getBody();
     $data = Json::decode($json);
     $messages = [];
     // flatten plural strings
     foreach ($data as $key => $value) {
         if (is_array($value)) {
             $vals = [];
             foreach ($value as $k => $v) {
                 $vals[] = sprintf('%s: %s', $k, $v);
             }
             $val = implode('|', $vals);
         } else {
             $val = $value;
         }
         $messages[$key] = str_replace(['{{', '}}'], '%', $val);
     }
     // put them into message catalog
     $catalogue = new MessageCatalogue($locale);
     $catalogue->add($messages, $domain);
     return $catalogue;
 }
开发者ID:keeko,项目名称:framework,代码行数:33,代码来源:KeekoJsonTranslationLoader.php

示例3: fileToArray

 private function fileToArray($filename)
 {
     $file = new File($filename);
     if (!$file->exists()) {
         throw new FileNotFoundException(sprintf('File not found at: %s', $filename));
     }
     return Json::decode($file->read());
 }
开发者ID:gossi,项目名称:swagger,代码行数:8,代码来源:KeekoTest.php

示例4: fromFile

 /**
  *
  * @param string $filename
  * @throws FileNotFoundException
  * @throws JsonException
  * @return static
  */
 public static function fromFile($filename)
 {
     $file = new File($filename);
     if (!$file->exists()) {
         throw new FileNotFoundException(sprintf('File not found at: %s', $filename));
     }
     $json = Json::decode($file->read());
     return new static($json);
 }
开发者ID:keeko,项目名称:framework,代码行数:16,代码来源:RootSchema.php

示例5: getJson

 /**
  *
  * @param BodyResource $file
  * @return array
  */
 private function getJson(BodyResource $file)
 {
     $config = Json::decode($file->getBody());
     // fix version
     if (!isset($config['version'])) {
         $config['version'] = 'dev-master';
     }
     return $config;
 }
开发者ID:keeko,项目名称:framework,代码行数:14,代码来源:PackageManager.php

示例6: run

 /**
  * Automatically generated method, will be overridden
  *
  * @param Request $request      	
  * @return Response
  */
 public function run(Request $request)
 {
     $json = Json::decode($request->getContent());
     $path = new JSONPath($json);
     $login = $path->find('$.data.attributes.login')->first();
     $password = $path->find('$.data.attributes.password')->first();
     $domain = new SessionDomain($this->getServiceContainer());
     $payload = $domain->login($login, $password);
     return $this->responder->run($request, $payload);
 }
开发者ID:keeko,项目名称:auth,代码行数:16,代码来源:LoginAction.php

示例7: run

 /**
  * Automatically generated run method
  * 
  * @param Request $request
  * @return Response
  */
 public function run(Request $request)
 {
     $body = Json::decode($request->getContent());
     if (!isset($body['data'])) {
         throw new InvalidParameterException();
     }
     $data = $body['data'];
     $domain = new JudgeDomain($this->getServiceContainer());
     $payload = $domain->create($data);
     return $this->responder->run($request, $payload);
 }
开发者ID:iuf,项目名称:junia,代码行数:17,代码来源:JudgeCreateAction.php

示例8: run

 /**
  * Automatically generated run method
  * 
  * @param Request $request
  * @return Response
  */
 public function run(Request $request)
 {
     $body = Json::decode($request->getContent());
     if (!isset($body['data'])) {
         throw new InvalidParameterException();
     }
     $data = $body['data'];
     $id = $this->getParam('id');
     $domain = new StartgroupDomain($this->getServiceContainer());
     $payload = $domain->setCompetitionId($id, $data);
     return $this->responder->run($request, $payload);
 }
开发者ID:iuf,项目名称:junia,代码行数:18,代码来源:StartgroupCompetitionUpdateAction.php

示例9: run

 /**
  * Automatically generated run method
  * 
  * @param Request $request
  * @return Response
  */
 public function run(Request $request)
 {
     $body = Json::decode($request->getContent());
     if (!isset($body['data'])) {
         throw new InvalidParameterException();
     }
     $data = $body['data'];
     $id = $this->getParam('id');
     $domain = new LocalizationDomain($this->getServiceContainer());
     $payload = $domain->updateLanguageVariant($id, $data);
     return $this->responder->run($request, $payload);
 }
开发者ID:keeko,项目名称:core,代码行数:18,代码来源:LocalizationLanguageVariantUpdateAction.php

示例10: run

 /**
  * Automatically generated run method
  * 
  * @param Request $request
  * @return Response
  */
 public function run(Request $request)
 {
     $body = Json::decode($request->getContent());
     if (!isset($body['data'])) {
         throw new InvalidParameterException();
     }
     $data = $body['data'];
     $id = $this->getParam('id');
     $domain = new RoutineDomain($this->getServiceContainer());
     $payload = $domain->setPerformanceChoreographyStatisticId($id, $data);
     return $this->responder->run($request, $payload);
 }
开发者ID:iuf,项目名称:junia,代码行数:18,代码来源:RoutinePerformanceChoreographyStatisticUpdateAction.php

示例11: updateApi

 private function updateApi(Module $model, ModuleSchema $module, $actions)
 {
     $repo = $this->service->getResourceRepository();
     $filename = sprintf('/packages/%s/api.json', $model->getName());
     if (!$repo->contains($filename)) {
         return;
     }
     // delete every api existent for the given module prior to create the new ones
     ApiQuery::create()->filterByActionId(array_values($actions))->delete();
     // 		$extensions = $this->service->getExtensionRegistry()->getExtensionsByPackage('keeko.api', $model->getName());
     $json = Json::decode($repo->get($filename)->getBody());
     $swagger = new Swagger($json);
     foreach ($swagger->getPaths() as $path) {
         /* @var $path Path */
         foreach (Swagger::$METHODS as $method) {
             if ($path->hasOperation($method)) {
                 $op = $path->getOperation($method);
                 $actionName = $op->getOperationId();
                 if (!isset($actions[$actionName])) {
                     continue;
                 }
                 // find required parameters
                 $required = [];
                 foreach ($op->getParameters() as $param) {
                     /* @var $param Parameter */
                     if ($param->getIn() == 'path' && $param->getRequired()) {
                         $required[] = $param->getName();
                     }
                 }
                 // 					$prefix = isset($extensions[$actionName])
                 // 						? $extensions[$actionName]
                 // 						: $module->getSlug();
                 $prefix = $module->getSlug();
                 $fullPath = str_replace('//', '/', $prefix . '/' . $path->getPath());
                 $api = new Api();
                 $api->setMethod($method);
                 $api->setRoute($fullPath);
                 $api->setActionId($actions[$actionName]);
                 $api->setRequiredParams(implode(',', $required));
                 $api->save();
             }
         }
     }
     $model->setApi(true);
     $model->save();
 }
开发者ID:keeko,项目名称:framework,代码行数:46,代码来源:ModuleInstaller.php

示例12: loadModules

 private function loadModules()
 {
     if (!empty($this->modules)) {
         return $this->modules;
     }
     $modules = [];
     $models = ModuleQuery::create()->filterByApi(true)->find();
     $repo = $this->service->getResourceRepository();
     foreach ($models as $model) {
         $package = $this->service->getPackageManager()->getPackage($model->getName());
         $filename = sprintf('/packages/%s/api.json', $model->getName());
         if ($repo->contains($filename)) {
             $routes = [];
             $json = Json::decode($repo->get($filename)->getBody());
             $swagger = new Swagger($json);
             foreach ($swagger->getPaths() as $path) {
                 /* @var $path Path */
                 foreach (Swagger::$METHODS as $method) {
                     if ($path->hasOperation($method)) {
                         $op = $path->getOperation($method);
                         $actionName = $op->getOperationId();
                         $routes[str_replace('-', '_', $actionName)] = ['method' => $method, 'path' => $path->getPath()];
                     }
                 }
             }
             $modules[] = ['title' => $model->getTitle(), 'slug' => $package->getKeeko()->getModule()->getSlug(), 'model' => $model, 'routes' => $routes];
         }
     }
     $this->modules = $modules;
     return $modules;
 }
开发者ID:keeko,项目名称:developer-app,代码行数:31,代码来源:DeveloperApplication.php

示例13: testDecodeBrokenStackDepth

 /**
  *
  * @expectedException \phootwork\json\JsonException
  * @expectedExceptionCode \phootwork\json\Json::ERROR_DEPTH
  */
 public function testDecodeBrokenStackDepth()
 {
     $json = json_encode([1 => ['English' => ['One', 'January'], 'French' => ['Une', 'Janvier']]]);
     Json::decode($json, 0, 3);
 }
开发者ID:phootwork,项目名称:json,代码行数:10,代码来源:JsonTest.php


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