Hi all,
Assuming the buffer length is all you need, it's slightly more efficient
to use json_dump_callback() with a function that sums the length of each
callback buffer, instead of completely assembling the results in a
single linear buffer and using strlen(). You can avoid a number of
malloc() and memcpy() calls this way.
As has been suggested, though, it does seem strange to calculate the
length of a JSON object without keeping the serialized version for
later.
cheers,
Graeme