serialize: escaping json strings should write in batches.

This significantly speeds up encoding json strings.