Skip to main content

JsonxConstructor

Derive Macro JsonxConstructor 

Source
#[derive(JsonxConstructor)]
{
    // Attributes available to this derive:
    #[jsonx]
}
Expand description

Derives JsonxConstructor — and the serde Serialize/Deserialize impls that wire it in — for a type that implements Display and FromStr.

The constructor name defaults to the type name, lowercased. Override it with #[jsonx(name = "...")]:

#[derive(jsonx::JsonxConstructor)]
#[jsonx(name = "semver")]
struct Version { major: u16, minor: u16 }
// (Version must also implement Display + FromStr)