Recommendation for JSON crate


I wonder if anyone can recommend a create that does JSON writing and loading?

The most popular one on on seems to be serde_json but I don't want to use that as it caused my compile/link times to become quite a bit longer when I tested it. Also I would like to avoid serde as I also want to save/load data that are not directly inside Rust structs.


The one I tend to use is rustc-serialize. You can dynamically create JSON objects using a BTreeMap<String, Json> structure.

Thanks! I see that the recommendation actually recommends Serde instead but I will give it a closer look.

rustc-serialize is less flexible and configurable than serde. I have done some manual deserialize-implementations using serde recently, and it's not as scary as it may look. Loading and saving things that are not directly inside structs will always be a bit clunky, but my solution for it was to make a temporary Config type that contains all the pieces I want, and then immediately tear it apart.

Yeah I actually realized I can solve it somewhat nice anyway.

My use-case is that I have plugins that can save/load state. The plugins can be written in whatever language and are provided a C API. What I will do is simple have the API (that is implemented on the Rust side) to build a Vec of Strings that can be filed in before the serialize of the structure.

So this can hopefully turn out nice anyway :slight_smile:

Edit: Now when I think about it the issue may have been that I used syntex to generate the bindings as I use the stable compiler as the auto-generation requires nightly otherwise.

Yes, syntex is one of the crates that takes the longest to compile, generally. That'd be why your times were longer.

Good to know. Thanks!