Iteratively encode JSON to avoid blocking the reactor.