AFAICS, with the current codebase, a new generator instance has to be created for each JSON value.
I'm implementing a protocol based on the exchange of JSON objects. For this use-case it is convenient and also more efficient to re-use the existing generator instance for the entire communication instead of re-allocating a new generator instance for each object/message. I hence implemented a new function to reset the generator state, tentatively named yajl_gen_reset().
From the source code comment added for that function:
/** completely reset the generator state. Using this function
* allows for a single generator instance to be used to generate a
* series of JSON values. This the counterpart to the
* yajl_allow_multiple_values parser option. */
encode: add function to completely reset generator state
thanks for the contribution! Sorry it's taken me so long - but now committed to master is basically this change. The only difference is that calling this will not clear the output buffer. Rationale is that the client may wish to generate multiple entities and to use the output buffer to stream all output. conflating a call to reset and a call to clear is less flexible than making them separate.
Thanks again for the contribution!