We could avoid JSON parsing altogether in some cases. For instance, right now when we create a document and receive a HTTP status 200 response, we parse the response, but we don't do anything about it. We probably could avoid this parsing. Not sure the performance impact would be high though, since we try to bulk such requests, and when receiving a bulk response we definitely need to parse the response (it contains the HTTP status code for each bulked request).
Let's investigate a bit whether 1) JSON parsing has a big impact on overall performance and 2) we can implement some kind of lazy parsing easily.
1. After a bit of profiling, it turns out that, regarding both allocations and execution time, the JSON writing is by far the most expensive operation (almost by an order of magnitude)
2. We mostly parse bulk responses, for which we definitely need parsing (so that we know the status code for each bulked operation)
For these reasons, optimizing parsing (making it more efficient) is likely a better approach than trying to avoid parsing: see