That’s about all I need to ask. Checked the PHP manual and saw a user post saying that serialize is 45-90% slower than json_encode (he ran some benchmarks). But how “slow” is slow? I can find a lot of “versus” stuff sprawling around but none of which a beginner like me can relate to.
I just wrote a script that encoded an array in json and another one to decode it. I did same with serialize. Obviuously that won’t tell me any significant differences between them.
If you’re transferring data between one application and another, it’s usually almost always better to use JSON encoded data rather than PHP serialized data as the later is a format specific to PHP and not as portable as JSON.
Even in a situation where both the server and client are both PHP-based, it behooves you to use a portable format like JSON to allow the creation of new clients in the future without having to change response format from the server.
I haven’t done any benchmarking of these two myself, but if you’re finding that json encoding is faster than serialization, than all the more reason to use it.
Also, I prefer JSON encoded data as it is easier to read than serialized data and can quickly be thrown into firebug to be visualized.