json icon indicating copy to clipboard operation
json copied to clipboard

Method for writing JSON into an existing string buffer

Open djc opened this issue 3 years ago • 0 comments

If I'm not mistaken, JSON output will always be UTF-8. However, as far as I know from the API, the to_string{,_pretty}() and to_vec{,_pretty}() functions allocate a new string buffer and the to_writer{,_pretty}() variants write into an abstraction based on bytes; that is, the invariant that the output JSON is UTF-8 must be enforced/clarified by the caller.

It would be nice if there was a way to write into a &mut String and/or a &mut std::fmt::Formatter<'_>.

djc avatar Feb 28 '22 16:02 djc