Memory optimizations

Replaced serialize/unserialize with json_encode/json_decode to reduce cache file size and memory peak usage (for cached version).

Previous values:
Without cache: 41.461456298828M
With cache: 15.801124572754M

New values:
Without cache: 41.448585510254 (-0,03%)
With cache: 13.756393432617 (-12,94%)