In an effort to save space for recording array information, I usually serialized the data. As I’m sure most developers did as well. On a lark, I just decided to check to see if serialize was saving more space that encoding the date via JSON. In doing so I found that JSON, as suspected, saves more space than serializing the information.

In my small, one array, test information is as follows:

  • Serialized data bytes: 320
  • JSON encoded bytes: 249

For those who are either rushing for a calculator, or haven’t had their coffee this morning and are unable to do math. That means that the JSON information saved roughly 22% space. That’s a pretty significant savings, or could be given the information encoded was larger.

That could save quite a bit of information while saving information to databases or files. Which could, in theory, reduce server load and database server load, especially on shared hosting servers.

Tags: ,

Leave a Reply

Your email address will not be published. Required fields are marked *