examples/parts/mixed_arrays.rs
1use serde_json::json;
2use toon_format::encode_default;
3
4pub fn mixed_arrays() {
5 // Mixed / non-uniform arrays (list format)
6 let mixed = json!({
7 "items": [1, {"a": 1}, "text"]
8 });
9 println!("{}", encode_default(&mixed).unwrap());
10
11 // Objects in list format: first field on hyphen line
12 let list_objects = json!({
13 "items": [
14 {"id": 1, "name": "First"},
15 {"id": 2, "name": "Second", "extra": true}
16 ]
17 });
18 println!("\n{}", encode_default(&list_objects).unwrap());
19}