back to web

Condensed JSON


Get it on GitHub
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:


$cjsonSTR = CondensedJSON::encodeJSON($obj);
$obj = CondensedJSON::decodeJSON(cjsonSTR);


JavaScript Usage:


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