Comparison between rustc-serialize and serde_json

I wonder what is the difference between these two crates for serializing/deserializing JSON.
Is one recommended over the other? Is one faster? etc.

It's just that I don't want to have to support both if I can avoid it :slight_smile:

3 Likes

I recently switched to serde_json for one of my projects. Here is my take on it:

Benefits of serde_json over rustc-serialize:

  • easier to use: it allows you to use #[derive(Serialize, Deserialize)] and changing the name of fields using annotations (#[serde(rename="bla")]) and declare specific functions to ser/deser a field (#[serde(deserialize_with="deser_func")]) etc.
  • better documentation
  • more flexible
  • more actively maintained
  • it's constantly improving

Drawbacks of serde_json compared to rustc-serialize:

  • it is inconvenient to use on stable rust as compiler plugins are not allowed
  • longer build times
  • needs nightly for better error messages

Overall I am pretty happy with serde_json and I am planning to switch all my projects to it.

1 Like