How safe is it to call serde_json::to_string(o).unwrap()? The documentation states that Serialization can fail if T's implementation of Serialize decides to fail, or if T contains a map with non-string keys. It looks to me like calling unwrap is safe here but I want to be sure? Am I overlooking something?
If you know all cases in which serde_json::to_string() might return a Result::Err and you can prove that your code only serializes objects that will never trigger any of these conditions, you can .expect() the result with an appropriate message that clarifies the reasoning why this can never happen and, if it does, that this is a bug. E.g.:
let string = serde_json::to_string(o).expect("Serializing an o can never trigger a serialization error, because trust me. This is a bug.");
I don't know. How is serde::Serialize implemented on Value?
Other than the documented non string (or, apparently, number) map keys, and errors forwarded from the Serialize implementation, looks like numbers being out of range when arbitrary_precision feature isn't enabled will also error?