r o b l o g

JSON - by the code for the code

Just finished building the json flash feed:
http://blog.robshearing.com/wp-flash-json.php

I used a handy php JSON parser to encode the string. I’m not entirely convinced about JSON. Evangelists go on about it’s inherent readability, however characters have to be escaped and this results in some messy looking text. I see this notation best suited for code and not for humans to read. It’s best if it’s encoded by code and then decoded by code and never sees the light of day. In this respect it is a very readable notation, lightweight and easy to ingest.

For example:
encoding (using PHP JSON parser):
$output = $json->encode($json_feed);

decoding (using adobe’s AS3 JSON parser):
var myObject:Object = JSON.decode( jsonString );

I don’t think it’ll ever replace xml. If I have to manage the data myself I will opt for xml - I can add comments, I can add CDATA, I can waste time deciding whether to use attributes or text nodes and I can take pleasure in making it look nice. But if I just want to shift a big chunky object from one platform to another I’l be encoding with JSON.

No comments yet. Be the first.

Leave a reply

Mexico