Stream encoding
mghicho opened this issue · 2 comments
Has there been any work done to implement stream encoder?
I'm thinking of taking a look at it.
Hi @mghicho, not really, but the current encoders can be used to encode e.g. an array or a map in a streaming manner by calling e.g. cbor_encode_indef_array_start
and then encoding individual items and terminating, flushing buffers as needed. What would the API you have in mind look like?
Hi,
Sorry I somehow missed the notification that you replied.
I actually went with the same method your suggested, it was enough for my application.
But when I was exploring ideas, I thought of an api that you can feed it your json text in a streaming fashion, and receive whatever binary is prepared at that time, something like:
streaming_encode(
char* jsonText, ///< [IN]
int jsonTextLength, ///< [IN]
uint8_t outBuffer, ///< [OUT]
int* outBufferLengthPtr ///< [OUT])