Skip to main content

Crate prost_canonical_serde_derive

Crate prost_canonical_serde_derive 

Source
Expand description

Proc macros that derive canonical JSON serde implementations for prost types.

These derives implement serde::Serialize and serde::Deserialize using canonical protobuf JSON rules, so callers can keep using serde_json normally.

§Example

use prost_canonical_serde::{CanonicalDeserialize, CanonicalSerialize};

#[derive(CanonicalSerialize, CanonicalDeserialize)]
struct Example {
    #[prost(int32, tag = "1")]
    #[prost_canonical_serde(proto_name = "value", json_name = "value")]
    value: i32,
}

let json = serde_json::to_string(&Example { value: 1 }).unwrap();

Derive Macros§

CanonicalDeserialize
Derives CanonicalDeserialize and serde::Deserialize for prost messages.
CanonicalSerialize
Derives CanonicalSerialize and serde::Serialize for prost messages.