PHP Classes

File: classes/TJsonHandler/example.php

Recommend this page to a friend!
  Classes of ASCOOS CMS   AFW Examples   classes/TJsonHandler/example.php   Download  
File: classes/TJsonHandler/example.php
Role: Example script
Content type: text/plain
Description: Example for JSON encoding and decoding
Class: AFW Examples
Examples and tests of usage of Ascoos Framework
Author: By
Last change:
Date: 5 days ago
Size: 532 bytes
 

Contents

Class file image Download
<?php
global $afw_path; // ASCOOS FRAMEWORK PATH

require_once $afw_path."/extras/encoders/json.php";

use
ASCOOS\FRAMEWORK\Extras\Encoders\Json\TJsonHandler;

$json = new TJsonHandler();
$data = ["name" => "AlexSoft Software", "age" => 30];
$encoded = $json->encode($data);
$decoded = $json->decode($encoded);

echo
"Encoded: $encoded\n"; // ?????????: {"name":"AlexSoft Software","age":30}
var_dump($decoded); // ?????????: array(2) { ["name"]=> string(7) "AlexSoft Software" ["age"]=> int(30) }
?>