Skip to content

Commit

Permalink
Update version 1.6.0
Browse files Browse the repository at this point in the history
             Fix README.md
  • Loading branch information
tcorral committed Nov 2, 2013
1 parent c984a8d commit 4074d8a
Show file tree
Hide file tree
Showing 111 changed files with 92,362 additions and 592 deletions.
Binary file added Benchmark/Benchmark_Results.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 32 additions & 0 deletions Benchmark/obj/demo_pack_gzip_compress_with_base64/GzipJSON.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
/**
* Class GzipJSON
* Class to decompress gzipped string to JSON.
*/
class GzipJSON {
/**
* Private method that implements the inflate of the data.
* @param $data
* @private
* @return string
*/
private function decode_gzip( $data )
{
return gzinflate( substr( $data, 10, -8 ) );
}

/**
* Method that returns an associated array via json_decode;
* @param $data
* @return mixed
*/
function decompress( $data )
{
$json = json_decode( $this->decode_gzip( utf8_decode( base64_decode( $data ) ) ));
if ( is_null( $json ) )
{
$json = json_decode( $data );
}
return $json;
}
}
10 changes: 10 additions & 0 deletions Benchmark/obj/demo_pack_gzip_compress_with_base64/alo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
include_once('GzipJSON.php');

if ( isset( $_POST['json'] ) )
{
$gzjson = new GzipJSON();
$json = $gzjson->decompress($_POST['json']);
$json->test2 = 3;
echo json_encode($json);
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
152 changes: 2 additions & 150 deletions demo/index.php → ..._pack_gzip_compress_with_base64/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -2406,157 +2406,9 @@
</div>
<script src="http:https://code.jquery.com/jquery-2.0.2.min.js"></script>
<script src="http:https://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script src="data/data2.js"></script>
<script src="js/jsonc.js"></script>
<script src="data/data.js"></script>
<script src="data/data2.js"></script>
<script>
$(function() {
$( "#accordion_data, #accordion_usage, #accordion_server" ).accordion( { active: false, collapsible: true } );
$("#clean_compress_json_data_button").click(function()
{
$("#results_compress_json_data").html("");
return false;
});
$("#compress_json_data_1_button").click(function(event)
{
var compressedJSON = JSONC.compress( obj );
var stringCompressedJSON = JSON.stringify(compressedJSON);
$("#results_compress_json_data").html( "<div class='size'>" + stringCompressedJSON.length + " bytes.</div> <div>" + stringCompressedJSON + "</div>");
return false;
});
$("#compress_json_data_2_button").click(function(event)
{
var compressedJSON = JSONC.compress( obj2 );
var stringCompressedJSON = JSON.stringify(compressedJSON);
$("#results_compress_json_data").html( "<div class='size'>" + stringCompressedJSON.length + " bytes.</div> <div>" + stringCompressedJSON + "</div>" );
return false;
});
$("#clean_pack_json_data_button").click(function()
{
$("#results_pack_json_data").html("");
return false;
});
$("#pack_json_data_1_button").click(function(event)
{
var stringCompressedJSON = JSONC.pack( obj );
$("#results_pack_json_data").html( "<div class='size'>" + stringCompressedJSON.length + " bytes.</div> <div>" + stringCompressedJSON + "</div>");
return false;
});
$("#pack_json_data_2_button").click(function(event)
{
var stringCompressedJSON = JSONC.pack( obj2 );
$("#results_pack_json_data").html( "<div class='size'>" + stringCompressedJSON.length + " bytes.</div> <div>" + stringCompressedJSON + "</div>" );
return false;
});
$("#clean_pack_compress_json_data_button").click(function()
{
$("#results_pack_compress_json_data").html("");
return false;
});
$("#pack_compress_json_data_1_button").click(function(event)
{
var stringCompressedJSON = JSONC.pack( obj, true );
$("#results_pack_compress_json_data").html( "<div class='size'>" + stringCompressedJSON.length + " bytes.</div> <div>" + stringCompressedJSON + "</div>");
return false;
});
$("#pack_compress_json_data_2_button").click(function(event)
{
var stringCompressedJSON = JSONC.pack( obj2, true );
$("#results_pack_compress_json_data").html( "<div class='size'>" + stringCompressedJSON.length + " bytes.</div> <div>" + stringCompressedJSON + "</div>" );
return false;
});
$("#clean_decompress_json_data_button").click(function()
{
$("#results_decompress_json_data").html("");
return false;
});
$("#decompress_json_data_1_button").click(function(event)
{
var oComp = JSONC.compress( obj );
var stringCompressedJSON = JSON.stringify( JSONC.decompress( oComp ) );
$("#results_decompress_json_data").html( "<div class='size'>" + stringCompressedJSON.length + " bytes.</div> <div>" + stringCompressedJSON + "</div>");
return false;
});
$("#decompress_json_data_2_button").click(function(event)
{
var oComp = JSONC.compress( obj2 );
var stringCompressedJSON = JSON.stringify( JSONC.decompress( oComp ) );
$("#results_decompress_json_data").html( "<div class='size'>" + stringCompressedJSON.length + " bytes.</div> <div>" + stringCompressedJSON + "</div>" );
return false;
});
$("#clean_unpack_json_data_button").click(function()
{
$("#results_unpack_json_data").html("");
return false;
});
$("#unpack_json_data_1_button").click(function(event)
{
var gzipped = JSONC.pack( obj );
var stringCompressedJSON = JSON.stringify( JSONC.unpack( gzipped ) );
$("#results_unpack_json_data").html( "<div class='size'>" + stringCompressedJSON.length + " bytes.</div> <div>" + stringCompressedJSON + "</div>");
return false;
});
$("#unpack_json_data_2_button").click(function(event)
{
var gzipped = JSONC.pack( obj2 );
var stringCompressedJSON = JSON.stringify( JSONC.unpack( gzipped ) );
$("#results_unpack_json_data").html( "<div class='size'>" + stringCompressedJSON.length + " bytes.</div> <div>" + stringCompressedJSON + "</div>" );
return false;
});
$("#clean_unpack_compress_json_data_button").click(function()
{
$("#results_unpack_compressed_json_data").html("");
return false;
});
$("#unpack_compress_json_data_1_button").click(function(event)
{
var gzipped = JSONC.pack( obj, true );
var stringCompressedJSON = JSON.stringify( JSONC.unpack( gzipped, true ) );
$("#results_unpack_compressed_json_data").html( "<div class='size'>" + stringCompressedJSON.length + " bytes.</div> <div>" + stringCompressedJSON + "</div>");
return false;
});
$("#unpack_compress_json_data_2_button").click(function(event)
{
var gzipped = JSONC.pack( obj2, true );
var stringCompressedJSON = JSON.stringify( JSONC.unpack( gzipped, true ) );
$("#results_unpack_compressed_json_data").html( "<div class='size'>" + stringCompressedJSON.length + " bytes.</div> <div>" + stringCompressedJSON + "</div>" );
return false;
});
});
$("form").submit(function(event)
{
var sObj, nLenObjStr, sZipped, nLenZipped;
sObj = JSON.stringify( obj );
nLenObjStr = sObj.length;
sZipped = JSONC.pack( obj );
//sZipped = JSONC.pack( obj, true ); //version compact
nLenZipped = sZipped.length;
console.log( 'Original:', sObj, sObj.length );
console.log( 'Send:', sZipped, sZipped.length );
$.ajax({
url: "/demo/alo.php",
type: "POST",
data: { json: nLenObjStr > nLenZipped ? sZipped : sObj },
dataType: 'json',
success: function( data )
{
document.getElementById('info_server').innerHTML = 'Press F12 to open developer tools and check the console tab';
//data = JSONC.decompress( data ); //version compact
console.log('Data:', data, JSON.stringify(data).length);
},
error: function()
{
console.log.apply(console, arguments);
}
});
event.preventDefault();
});
</script>
<script src="js/app.js"></script>
</body>
</html>
146 changes: 146 additions & 0 deletions Benchmark/obj/demo_pack_gzip_compress_with_base64/js/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
$(function() {
$( "#accordion_data, #accordion_usage, #accordion_server" ).accordion( { active: false, collapsible: true } );
$("#clean_compress_json_data_button").click(function()
{
$("#results_compress_json_data").html("");
return false;
});
$("#compress_json_data_1_button").click(function(event)
{
var compressedJSON = JSONC.compress( obj );
var stringCompressedJSON = JSON.stringify(compressedJSON);
$("#results_compress_json_data").html( "<div class='size'>" + stringCompressedJSON.length + " bytes.</div> <div>" + stringCompressedJSON + "</div>");
return false;
});
$("#compress_json_data_2_button").click(function(event)
{
var compressedJSON = JSONC.compress( obj2 );
var stringCompressedJSON = JSON.stringify(compressedJSON);
$("#results_compress_json_data").html( "<div class='size'>" + stringCompressedJSON.length + " bytes.</div> <div>" + stringCompressedJSON + "</div>" );
return false;
});
$("#clean_pack_json_data_button").click(function()
{
$("#results_pack_json_data").html("");
return false;
});
$("#pack_json_data_1_button").click(function(event)
{
var stringCompressedJSON = JSONC.pack( obj );
$("#results_pack_json_data").html( "<div class='size'>" + stringCompressedJSON.length + " bytes.</div> <div>" + stringCompressedJSON + "</div>");
return false;
});
$("#pack_json_data_2_button").click(function(event)
{
var stringCompressedJSON = JSONC.pack( obj2 );
$("#results_pack_json_data").html( "<div class='size'>" + stringCompressedJSON.length + " bytes.</div> <div>" + stringCompressedJSON + "</div>" );
return false;
});

$("#clean_pack_compress_json_data_button").click(function()
{
$("#results_pack_compress_json_data").html("");
return false;
});
$("#pack_compress_json_data_1_button").click(function(event)
{
var stringCompressedJSON = JSONC.pack( obj, true );
$("#results_pack_compress_json_data").html( "<div class='size'>" + stringCompressedJSON.length + " bytes.</div> <div>" + stringCompressedJSON + "</div>");
return false;
});
$("#pack_compress_json_data_2_button").click(function(event)
{
var stringCompressedJSON = JSONC.pack( obj2, true );
$("#results_pack_compress_json_data").html( "<div class='size'>" + stringCompressedJSON.length + " bytes.</div> <div>" + stringCompressedJSON + "</div>" );
return false;
});

$("#clean_decompress_json_data_button").click(function()
{
$("#results_decompress_json_data").html("");
return false;
});
$("#decompress_json_data_1_button").click(function(event)
{
var oComp = JSONC.compress( obj );
var stringCompressedJSON = JSON.stringify( JSONC.decompress( oComp ) );
$("#results_decompress_json_data").html( "<div class='size'>" + stringCompressedJSON.length + " bytes.</div> <div>" + stringCompressedJSON + "</div>");
return false;
});
$("#decompress_json_data_2_button").click(function(event)
{
var oComp = JSONC.compress( obj2 );
var stringCompressedJSON = JSON.stringify( JSONC.decompress( oComp ) );
$("#results_decompress_json_data").html( "<div class='size'>" + stringCompressedJSON.length + " bytes.</div> <div>" + stringCompressedJSON + "</div>" );
return false;
});

$("#clean_unpack_json_data_button").click(function()
{
$("#results_unpack_json_data").html("");
return false;
});
$("#unpack_json_data_1_button").click(function(event)
{
var gzipped = JSONC.pack( obj );
var stringCompressedJSON = JSON.stringify( JSONC.unpack( gzipped ) );
$("#results_unpack_json_data").html( "<div class='size'>" + stringCompressedJSON.length + " bytes.</div> <div>" + stringCompressedJSON + "</div>");
return false;
});
$("#unpack_json_data_2_button").click(function(event)
{
var gzipped = JSONC.pack( obj2 );
var stringCompressedJSON = JSON.stringify( JSONC.unpack( gzipped ) );
$("#results_unpack_json_data").html( "<div class='size'>" + stringCompressedJSON.length + " bytes.</div> <div>" + stringCompressedJSON + "</div>" );
return false;
});


$("#clean_unpack_compress_json_data_button").click(function()
{
$("#results_unpack_compressed_json_data").html("");
return false;
});
$("#unpack_compress_json_data_1_button").click(function(event)
{
var gzipped = JSONC.pack( obj, true );
var stringCompressedJSON = JSON.stringify( JSONC.unpack( gzipped, true ) );
$("#results_unpack_compressed_json_data").html( "<div class='size'>" + stringCompressedJSON.length + " bytes.</div> <div>" + stringCompressedJSON + "</div>");
return false;
});
$("#unpack_compress_json_data_2_button").click(function(event)
{
var gzipped = JSONC.pack( obj2, true );
var stringCompressedJSON = JSON.stringify( JSONC.unpack( gzipped, true ) );
$("#results_unpack_compressed_json_data").html( "<div class='size'>" + stringCompressedJSON.length + " bytes.</div> <div>" + stringCompressedJSON + "</div>" );
return false;
});
});
$("form").submit(function(event)
{
var sObj, nLenObjStr, sZipped, nLenZipped;
sObj = JSON.stringify( obj );
nLenObjStr = sObj.length;
sZipped = JSONC.pack( obj, true );
nLenZipped = sZipped.length;

console.log( 'Original:', sObj, nLenObjStr );
console.log( 'Send:', sZipped, nLenZipped );
$.ajax({
url: "/obj/demo_pack_gzip_compress_with_base64/alo.php",
type: "POST",
data: { json: sZipped },
dataType: 'json',
success: function( data )
{
document.getElementById('info_server').innerHTML = 'Press F12 to open developer tools and check the console tab';
data = JSONC.decompress( data ); //version compact
console.log('Data:', data, JSON.stringify(data).length);
},
error: function()
{
console.log.apply(console, arguments);
}
});
event.preventDefault();
});
Loading

0 comments on commit 4074d8a

Please sign in to comment.