Skip to content
PHP
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github
src
tests
.gitattributes
.gitignore
.scrutinizer.yml
.styleci.yml
.travis.yml
CHANGELOG.md
LICENSE.md
README.md
composer.json
phpunit.xml.dist

README.md

Yii JSON


The package provides methods to encode and decode JSON.

  • It throws \JsonException even if PHP version is lower than 7.3.
  • It has sensible defaults so you don't have to specify flags all the time.
  • It has handy methods to encode for HTML safely.
  • It handles \JsonSerializable and \SimpleXMLElement well.

Latest Stable Version Total Downloads Build Status Scrutinizer Code Quality Code Coverage

General usage

Encoding:

use \Yiisoft\Json\Json;

$data = ['name' => 'Alex', 'team' => 'Yii'];
$json = Json::encode($data);

Encoding for HTML:

use \Yiisoft\Json\Json;

$data = ['name' => 'Alex', 'team' => 'Yii'];
$json = Json::htmlEncode($data);

Decoding:

use \Yiisoft\Json\Json;

$json = '{"name":"Alex","team":"Yii"}';
$data = Json::decode($json);
You can’t perform that action at this time.