serialize: Remove allocations from escaping strs and indenting spaces

This speeds up json serialization by removing most of the allocations.