lib/serialization: extract caches from json_serialization