Skip to main content

Json

Derive Macro Json 

Source
#[derive(Json)]
{
    // Attributes available to this derive:
    #[postgresql]
    #[pg]
}
Expand description

Derives json / jsonb encoding and decoding for a type.

The type must also derive serde::Serialize (to be written as a parameter or COPY field) and serde::Deserialize (to be read from a result column). The generated impls map the whole value to a single jsonb column: FromSql, ToSql, StaticType, FromRow and RowShape.

Because it defines FromRow and RowShape, a type cannot derive both Json and FromRow; use postgresql::Json<T> for the JSON role in that case.