json
json copied to clipboard
Method for writing JSON into an existing string buffer
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<'_>.