File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -157,3 +157,47 @@ enum Data {
157157
158158The ` serde ` crate's "alloc" Cargo feature must be enabled to deserialize an
159159untagged tagged enum. (It is enabled by default.)
160+
161+ ## Sequence format of the adjacently and internally tagged representations
162+
163+ Both the adjacently tagged and internally tagged representations can be
164+ expressed either via map or sequence syntax. For example:
165+
166+ ``` rust
167+ #[derive(Debug , Serialize , Deserialize )]
168+ #[serde(tag = " type" , content = " x" )]
169+ enum MyType {
170+ Topic (i64 ), Sidebar (i64 )
171+ }
172+
173+ fn main () {}
174+ ```
175+
176+ is equivalent to both
177+
178+ ``` json
179+ [ " Topic" , 1 ]
180+ ```
181+
182+ and
183+
184+ ``` json
185+ { "type" : " Topic" , "x" : 1 }
186+ ```
187+
188+ ### Disable the sequence format
189+
190+ * (since serde v1.1.0)*
191+
192+ In case you want to disable the sequence format, you can use the
193+ ` #[serde(seq=false)] ` .
194+
195+ ``` rust
196+ #[derive(Debug , Serialize , Deserialize )]
197+ #[serde(tag = " type" , content = " x" , seq= false)]
198+ enum MyType {
199+ Topic (i64 ), Sidebar (i64 )
200+ }
201+ ```
202+
203+ will casue the sequence syntax to be disabled.
You can’t perform that action at this time.
0 commit comments