back to web

Condensed JSON

 

Get it on GitHub
JSON InCJSON OutJSON Out
C[["id","abbreviation","name"],[1,"appl","Apple"],[2,"pear","Pear"],[3,"bana","Banana"],[4,"bkby","Blackberry"],[5,"strw","Stawberry"],[5,"pech","Peach"],[6,"plum","Plum"]][{"id":1,"abbreviation":"appl","name":"Apple"},{"id":2,"abbreviation":"pear","name":"Pear"},{"id":3,"abbreviation":"bana","name":"Banana"},{"id":4,"abbreviation":"bkby","name":"Blackberry"},{"id":5,"abbreviation":"strw","name":"Stawberry"},{"id":5,"abbreviation":"pech","name":"Peach"},{"id":6,"abbreviation":"plum","name":"Plum"}]
331 Characters172331

 

For large groups of repeating data (ie database select results), significantly reduce the size of your JSON string by removing the duplicated key definitions. Restore them after a successful transmission to process as normal. Great for reducing bandwidth and transmission delays, and reduce storage space when used for saving data. Classes written for PHP and JavaScript make this a simple to apply tool for client server relationships.

 

Currently only supports arrays at the first and second levels of an object. If there are arrays in objects that are in objects that are properties of the primary object (or deeper), then they won't be compressed. Note also that it will only compress arrays at one level or the other, not both. In the above example the page loads with a simple php example. You can then load your own examples dynamically with JavaScript.

 

PHP Usage:

 

include_once("CondensedJSON.class.php");
$cjsonSTR = CondensedJSON::encodeJSON($obj);
$obj = CondensedJSON::decodeJSON(cjsonSTR);

 

JavaScript Usage:

 

var CJSON = new CondensedJSON();
var CJSONStr = CJSON.encodeJSON(obj);
obj = CJSON.decodeJSON(CJSONStr);