pub struct JsonConfig { /* private fields */ }
Expand description
Configuration options for JsonBuilder
Implementations§
Source§impl JsonConfig
JsonBuilder configuration options
impl JsonConfig
JsonBuilder configuration options
Sourcepub fn new() -> JsonConfig
pub fn new() -> JsonConfig
Initialze a new JsonConfig instance.
This uses the builder pattern. All options are initialized to None
and can be set using
self
s methods. Any options not set will use their defaults upon call to finalize
.
Sourcepub fn charkey<T: Into<String>>(&mut self, key: T) -> &mut JsonConfig
pub fn charkey<T: Into<String>>(&mut self, key: T) -> &mut JsonConfig
Key to store character content under.
("_"
by default)
Sourcepub fn attrkey<T: Into<String>>(&mut self, key: T) -> &mut JsonConfig
pub fn attrkey<T: Into<String>>(&mut self, key: T) -> &mut JsonConfig
Key to outer object containing tag attributes.
("$"
by default)
Sourcepub fn empty_tag<T: Into<String>>(&mut self, key: T) -> &mut JsonConfig
pub fn empty_tag<T: Into<String>>(&mut self, key: T) -> &mut JsonConfig
The value of empty nodes.
Can be used if you want to specify a value other than ""
for empty nodes.
(""
by default)
Sourcepub fn explicit_root(&mut self, flag: bool) -> &mut JsonConfig
pub fn explicit_root(&mut self, flag: bool) -> &mut JsonConfig
Sets the root node inside the resulting object.
(true
by default)
Sourcepub fn trim(&mut self, flag: bool) -> &mut JsonConfig
pub fn trim(&mut self, flag: bool) -> &mut JsonConfig
Trim whitespace at the beginning and end of text nodes.
(false
by default)
Sourcepub fn ignore_attrs(&mut self, flag: bool) -> &mut JsonConfig
pub fn ignore_attrs(&mut self, flag: bool) -> &mut JsonConfig
Ingore attributes.
Setting this to true will skip adding element attributes and create text nodes.
(false
by default)
Sourcepub fn merge_attrs(&mut self, flag: bool) -> &mut JsonConfig
pub fn merge_attrs(&mut self, flag: bool) -> &mut JsonConfig
Merge attributes.
Merge all XML attributes and child elements as properties of the parent, instead of keying
attributes off of the child attribute object. This option will be ignored if ignore_attrs
is set.
(false
by default)
Sourcepub fn normalize_text(&mut self, flag: bool) -> &mut JsonConfig
pub fn normalize_text(&mut self, flag: bool) -> &mut JsonConfig
Removes whitespace character data in text nodes.
This option will result in behavior that is a superset of trim
. Whitespace at the
beginning and end of text nodes will be trimmed. In addition, blank space (/s
) between
other text data will be converted to a single space (" "
). Corresponds to the normalize
option in node-xmlj2.
(false
by default)
Normalize all tags by converting them to lowercase.
Corresponds to the normalizeTags
option in node-xml2js.
(false
by default)
Sourcepub fn explicit_array(&mut self, flag: bool) -> &mut JsonConfig
pub fn explicit_array(&mut self, flag: bool) -> &mut JsonConfig
Always put the child nodes in an array, otherwise an array is only created if there is more than one child.
(true
by default)
Sourcepub fn explicit_charkey(&mut self, flag: bool) -> &mut JsonConfig
pub fn explicit_charkey(&mut self, flag: bool) -> &mut JsonConfig
Always store character data under charkey
even if there are are no other text elements
stored inside the tag.
(false
by default)
Sourcepub fn finalize(&self) -> JsonBuilder
pub fn finalize(&self) -> JsonBuilder
Finalize configuration options and build a JsonBuilder instance