PHP code example of cwola / jsonc
1. Go to this page and download the library: Download cwola/jsonc library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
cwola / jsonc example snippets
$value = <<< JSONC
/**
* JSON with Comments for PHP.
* DOC BLOCK.
*/
// Line comment.
{
"id": "xxx", // Identify
"name": "jhon doe" // your name
"age": 0,
"keyword": [
"xxx", 1, -5
]
}
JSONC;
$json = Cwola\Jsonc\decode($value);
echo $json['name']; // jhon doe
echo Cwola\Jsonc\toJson($value); // output json string
echo Cwola\Jsonc\toXml($value); // output xml string
echo Cwola\Jsonc\toReadableAST($value); // output Abstract Syntax Tree