Learn

Learn how to use facet for serialization, deserialization, and more.

Getting Started

Add facet to your project:

[dependencies]
facet = "1"
facet-json = "1"  # or facet-yaml, facet-toml, facet-kdl, etc.

Derive Facet on your types:

use facet::Facet;

#[derive(Facet)]
struct Person {
    name: String,
    age: u32,
}

Serialize and deserialize:

use facet_json::{from_str, to_string};

let person = Person { name: "Alice".into(), age: 30 };
let json = to_string(&person);  // {"name":"Alice","age":30}

let parsed: Person = from_str(&json)?;

Guides

Format Crates

FormatCrateDescription
JSONfacet-jsonJSON serialization/deserialization
YAMLfacet-yamlYAML support
TOMLfacet-tomlTOML configuration files
KDLfacet-kdlKDL document language
MessagePackfacet-msgpackBinary format

See the format comparison matrix for detailed feature support.