1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
use crate::*;
/// Determines the objects style.
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct ObjectsStyle {
/// Whether to use quotes to surround keys
///
/// ```
/// use doku::Document;
///
/// #[derive(Document)]
/// struct Person {
/// name: String,
/// }
///
/// let fmt_no_quotes = doku::json::Formatting {
/// objects_style: doku::json::ObjectsStyle { surround_keys_with_quotes: false, ..Default::default() },
/// ..Default::default()
/// };
///
/// let doc = doku::to_json_fmt::<Person>(&fmt_no_quotes);
///
/// doku::assert_doc!(r#"
/// {
/// name: "string"
/// }
/// "#, doc);
///
/// let fmt_quotes = doku::json::Formatting {
/// objects_style: doku::json::ObjectsStyle { surround_keys_with_quotes: true, ..Default::default() },
/// ..Default::default()
/// };
///
/// let doc = doku::to_json_fmt::<Person>(&fmt_quotes);
///
/// doku::assert_doc!(r#"
/// {
/// "name": "string"
/// }
/// "#, doc);
/// ```
pub surround_keys_with_quotes: bool,
/// Whether to use comma to separate properties
///
/// ```
/// use doku::Document;
///
/// #[derive(Document)]
/// struct Person {
/// name: String,
/// address: String,
/// }
///
/// let fmt_no_quotes = doku::json::Formatting {
/// objects_style: doku::json::ObjectsStyle { use_comma_as_separator: false, ..Default::default() },
/// ..Default::default()
/// };
///
/// let doc = doku::to_json_fmt::<Person>(&fmt_no_quotes);
///
/// doku::assert_doc!(r#"
/// {
/// "name": "string"
/// "address": "string"
/// }
/// "#, doc);
///
/// let fmt_quotes = doku::json::Formatting {
/// objects_style: doku::json::ObjectsStyle { use_comma_as_separator: true, ..Default::default() },
/// ..Default::default()
/// };
///
/// let doc = doku::to_json_fmt::<Person>(&fmt_quotes);
///
/// doku::assert_doc!(r#"
/// {
/// "name": "string",
/// "address": "string"
/// }
/// "#, doc);
/// ```
pub use_comma_as_separator: bool,
}
impl Default for ObjectsStyle {
fn default() -> Self {
Self {
surround_keys_with_quotes: true,
use_comma_as_separator: true,
}
}
}