Skip to content
This repository was archived by the owner on Jan 24, 2019. It is now read-only.

Latest commit

History

History
68 lines (49 loc) · 1.76 KB

File metadata and controls

68 lines (49 loc) · 1.76 KB

No longer actively maintained. I work now with NodeJS and I recommand you to take a look at json5

JSON5-php

Build statusLicense

JSON5 parser for PHP.This library using kujirahand/JSON5-PHP as reference.

Requirements

  • PHP 5.5.11 or later
  • Composer
  • JSON extension
  • mbstring extension

Features

  • Parse JSON5 string
  • Parse JSON5 by file

Install

Use composer.

1, Download this library

Modify require directive in composer.json.

{
"require": {
"hiroto-k/json5-php": "~1.0"
}
}

2, Load vendor/autoload.php file

Please add require "vendor/autoload.php" in your php file.

3, Use JSON5 class

Example

<?phprequire"vendor/autoload.php";
useHirotoK\JSON5\JSON5;
$json5_string = "{hoge: 'foo',}";
// Return 'stdClass'$json_object = JSON5::decode($json5_string);
// Return 'array'$json_array = JSON5::decode($json5_string, true);
$json5_file = "./tests/files/example.json5";
// Pass file name or SplFileObject.// Return 'stdClass'$json_object = JSON5::decodeFile($json5_file);
$json_object = JSON5::decodeFile(newSplFileObject($json5_file));
// Return 'array'$json_array = JSON5::decodeFile($json5_file, true);
$json_array = JSON5::decodeFile(newSplFileObject($json5_file), true);

License

MIT License