PHP serialisation

18 Feb

Working with @FND to get a PHP script talking to TiddyWeb. (The same way it would talk to a MySQL server for persistence, but making RESTful HTTP calls.) Anyway, trivial stuff and we divvy up between JSON serialisation and making the HTTP call. Here's the JSON serialisation:

<?

????require_once "JSON.php";

????$teams = array(
???? ??"carlton" => "blues",
???? ??"collingwood" => "maggies",
???? ??"essendon" => "bombers",
???? ??"wins" => 16,
???? ??"managers" => array("president" => "bob", "caretaker"=>"harry" ),
???? ??"years" => array(1906, "1915-1915", FALSE)
????);

????$json = new Services_JSON();
????print($json->encode($teams));

?>

It's using Michael Mygurski's PHP library (http://mike.teczno.com/json.html) … now in PEAR.

Aside: Thanks to jQuery 1.4 making a big deal of it, I'm now using "" on the left-hand side (the hash keys), always. Whether in PHP (where I have to), Javascript (where it's possible not to), or wherever. It's the standard.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: