The "idiomatic" way to make a serde_json formatter is to implement the serde_json::ser::Formatter trait. That's exactly what this crate does, except it doesn't actually expose the implementation to users. Instead, it exposes a helper method called to_string, which hinders more advanced/complex use cases where one might want to pass around a pre-constructed serde_json::Serializer.
The "idiomatic" way to make a
serde_json
formatter is to implement theserde_json::ser::Formatter
trait. That's exactly what this crate does, except it doesn't actually expose the implementation to users. Instead, it exposes a helper method calledto_string
, which hinders more advanced/complex use cases where one might want to pass around a pre-constructedserde_json::Serializer
.