JSON -> HTML Converter-thingy.
I was bored, and I needed something to work on, so I made this:
And mah test file:
It's not any faster than outputting HTML via echo, or just using straight HTML, and it doesn't have any practical uses, but like I said, I was bored. Plus I wanted to see if it would work.
I'm not planning on developing it further, I just thought it was kinda cool.
I was bored, and I needed something to work on, so I made this:
PHP:
<?php
define('core.php', 1);
require_once('parser.php');
class hJSON extends JSONParser
{
private $parser;
private function Run()
{
$json = $this -> parser -> jsonDecoded;
if (isset($json['html']))
{
echo '<html>';
if (isset($json['html']['head'])) {
echo '<head>';
if(isset($json['html']['head']['title']))
echo '<title>' . $json['html']['head']['title'] . '</title>';
echo '</head>';
}
echo '</html>';
}
}
function __construct($fileName)
{
$this -> parser = new JSONParser($fileName);
$this -> Run();
}
PHP:
<?php
if (!defined('core.php'))
die('Direct access of this file is not allowed');
class JSONParser
{
protected $json;
protected $jsonDecoded;
function __construct($fileName)
{
$this -> json = file_get_contents($fileName);
$this -> jsonDecoded = json_decode($this -> json, true);
}
}
?>
And mah test file:
Code:
{
"html": {
"head": {
"title": "hello world!"
}
}
}
It's not any faster than outputting HTML via echo, or just using straight HTML, and it doesn't have any practical uses, but like I said, I was bored. Plus I wanted to see if it would work.
I'm not planning on developing it further, I just thought it was kinda cool.