PHP code example of sgoendoer / json
1. Go to this page and download the library: Download sgoendoer/json 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/ */
sgoendoer / json example snippets
use sgoendoer\json\JSONObject;
use sgoendoer\json\JSONArray;
$jsonObject = new JSONObject();
$jsonObject->put("key", "value");
$jsonObject->put("array", new JSONArray());
$jsonObject->put("object", new JSONObject('{"a", 1}'));
echo $jsonObject->get("key");
echo $jsonObject->write();
$phpStyleJSON = $jsonObject->toStdClass();
echo $phpStyleJSON->key;
echo json_encode($phpStyleJSON);