From 72af0896e89dcd92879c8aa3ead8aa81e4d23e71 Mon Sep 17 00:00:00 2001 From: Erick Tryzelaar Date: Mon, 7 Sep 2015 16:54:27 -0700 Subject: [PATCH] docs(codegen): Document annotations --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index 6c4f07fc..09ca8f36 100644 --- a/README.md +++ b/README.md @@ -578,6 +578,21 @@ impl serde::de::Visitor for PointVisitor { } ``` +Annotations +=========== + +`serde_codegen` and `serde_macros` support annotations that help to customize +how types are serialized. Here are the supported annotations: + +| Annotation | Function | +| ---------- | -------- | +| `#[serde(rename(json="name1", xml="name2"))` | Serialize this field with the given name for the given formats | +| `#[serde(default)` | If the value is not specified, use the `Default::default()` | +| `#[serde(rename="name")` | Serialize this field with the given name | +| `#[serde(skip_serializing)` | Do not serialize this value | +| `#[serde(skip_serializing_if_empty)` | Do not serialize this value if `$value.is_empty()` is `true` | +| `#[serde(skip_serializing_if_none)` | Do not serialize this value if `$value.is_none()` is `true` | + Serialization Formats Using Serde =================================