PHP code example of ljson / ljson
1. Go to this page and download the library: Download ljson/ljson 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/ */
ljson / ljson example snippets
random object with a pure function inside.
$person = [
"name" => "John",
"mail" => function ($msg) {
return [
"author" => "John",
"message" => $msg,
];
},
];
$personStr = \LJSON\LJSON::stringify($person);
$personVal = \LJSON\LJSON::parse($personStr);
$mailFunction = $personVal->mail;
$mail = $mailFunction("hello");// would crash with json_encode
echo $personStr . "\n";
echo \LJSON\LJSON::stringify($mail) . "\n";