serialize: Remove allocations from escaping strs and indenting spaces
serialize: escaping json strings should write in batches.

This significantly speeds up encoding json strings.
serialize: speed up json pretty printing by batch writing spaces
auto merge of #15419 : erickt/rust/json, r=pcwalton

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