json
json copied to clipboard
Document behavior of to_pretty_string when passing Value
trafficstars
From https://docs.rs/serde_json/1.0.68/serde_json/fn.to_string_pretty.html:

I assume that if I call
use serde_json::*;
to_string_pretty<Value>(...);
I can .unwrap() this result safely, is it right? Or Value's implementation of Serialize might decide to fail?
If it's the former, can I make a PR adding this piece of info to this doc page?
Looking at the source code, it seems Value's Serialize impl indeed cannot fail:
https://github.com/serde-rs/json/blob/931ee23b1abf6b302df7c20a3a5866bf1a8a33ca/src/value/ser.rs#L13-L36
I think a PR to state this in the docs is a good idea, although the docs should be added to Value, not to_string_pretty.