As I understand to encode an object into a string you can use the serialization API and auto generated encodable trait but when you want to manage how the encoding is done you have two choice : develop you own trait serialize::Decodable which is not so easy or use the trait ToJson which I found easier to implement. That what I wanted to explain.