[wp-hackers] Why not json or xml instead of serialised data inDB

Ryan McCue lists at rotorised.com
Tue Jun 28 06:57:04 UTC 2011


William P. Davis wrote:
> I would imagine JSON and XML especially require more resources to turn back into an array than serializing.
>    

Surprisingly not. From the tests I've done, json_encode is faster than 
serialize for most things (serialize only beat json_* for very small 
arrays), and the same for json_decode/unserialize.

Personally, I prefer json_encode/json_decode because I tend to be 
storing arrays instead of actual objects (or stdClass objects anyway), 
and the speed is worth it for me (I'm storing 10k+ objects).

YMMV,

--
Ryan McCue
<http://ryanmccue.info/>


More information about the wp-hackers mailing list