Add with-writer-to-string
Opened this issue · 3 comments
I think it would be nice to have the macro with-writer-to-string
(similar to the one in com.inuoe.jzon-tests
) included and exported from com.inuoe.jzon
. The same is probably also the case for a with-writer-to-string*
macro.
Or is there a specific reason why you didn't include it @Zulu-Inuoe ?
No specific reason, but I don't think it's super valuable to add since it'd only save people 1 line of code and have us have to support a new interface
In the tests I define that macro because I am repeatedly calling the writer fns with a fresh writer, but in a normal use-case, people will likely have 1 or 2 calls to with-writer
in which case they can simply
(with-output-to-string (s)
(jzon:with-writer (writer :stream s)
...))
I'll leave this open in case anyone feels strongly about it.
Somebody brought up today that with-writer
could take :stream nil
to mean "return a string", which I like better than this since it means one less function, and nil
doesn't mean anything else there anyways
+1