Serde alternatives

Is there an alternative to Serde for serialization/deserialization in Rust?

Minicbor for example, postcard

What is it you want to serialise/deserialise?

How about protobuf's crates.io: Rust Package Registry?

I deserialised a horrible proprietary binary format just by writing code to do it. No dependencies needed.

The value of serde is one party can define a format (De/Serializer, eg serde_json), while the other can define the structure (De/Serialize), with serde as (nearly) nothing but the interface between them.

Therefore, there's not too much value in an exact replacement of serde itself, as the problem statement effectively requires something fairly substantially similar for the solution, but also it then needs buy in from all the different formats, but maybe someone will find a way for those lines to cross at some point and makes a clearly better option.

But you probably don't need an exact replacement, you just either want to parse an existing format into your structures:

Or to implement such a format for yourself or others:

Note that you can often use the various serde_* packages without going through serde, eg serde_json::Value is just what JSON support looks like in nearly every other language.

1 Like

Bincode 2.0 has its own traits and derives that are optimized for its format. bincode - Rust

Miniserde is essentially the same thing but for JSON. miniserde - Rust

Then there's a true serde alternative, merde. merde - Rust

And if you want something totally different, there's rkyv. rkyv - Rust

2 Likes

Oh, the creativity when naming crates is sometimes astounding :laughing:

4 Likes

While it's currently indev, the crate treaty is targeted to be a strict upgrade to serde. Last I heard it was blocked on several side crates that the developer had to make for treaty to work, but that was a while ago.

(apologies, that was not meant to be a reply)

When learning Solana, borsh is recommended for serializing and deserializing.