Implemented disallow_unknown

* Added codegen for disallow_unknown
* ... with new default to ignore unknown values during deserialization
* Added ContainerAttrs
This commit is contained in:
John Heitmann
2016-01-10 19:34:48 -08:00
parent 59285f627b
commit bfac1a581c
8 changed files with 366 additions and 10 deletions
+9
View File
@@ -585,6 +585,8 @@ Annotations
`serde_codegen` and `serde_macros` support annotations that help to customize
how types are serialized. Here are the supported annotations:
Field Annotations:
| Annotation | Function |
| ---------- | -------- |
| `#[serde(rename(json="name1", xml="name2"))` | Serialize this field with the given name for the given formats |
@@ -594,6 +596,13 @@ how types are serialized. Here are the supported annotations:
| `#[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` |
Structure Annotations:
| Annotation | Function |
| ---------- | -------- |
| `#[serde(disallow_unknown)` | Always error during serialization when encountering unknown fields. When absent, unknown fields are ignored for self-describing formats like JSON. |
Serialization Formats Using Serde
=================================