Optimize case for traversables in JSON serialization