Struct JsonConfig

Source
pub struct JsonConfig { /* private fields */ }
Expand description

Configuration options for JsonBuilder

Implementations§

Source§

impl JsonConfig

JsonBuilder configuration options

Source

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 selfs methods. Any options not set will use their defaults upon call to finalize.

Source

pub fn charkey<T: Into<String>>(&mut self, key: T) -> &mut JsonConfig

Key to store character content under.

("_" by default)

Source

pub fn attrkey<T: Into<String>>(&mut self, key: T) -> &mut JsonConfig

Key to outer object containing tag attributes.

("$" by default)

Source

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)

Source

pub fn explicit_root(&mut self, flag: bool) -> &mut JsonConfig

Sets the root node inside the resulting object.

(true by default)

Source

pub fn trim(&mut self, flag: bool) -> &mut JsonConfig

Trim whitespace at the beginning and end of text nodes.

(false by default)

Source

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)

Source

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)

Source

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)

Source

pub fn lowercase_tags(&mut self, flag: bool) -> &mut JsonConfig

Normalize all tags by converting them to lowercase.

Corresponds to the normalizeTags option in node-xml2js.

(false by default)

Source

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)

Source

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)

Source

pub fn finalize(&self) -> JsonBuilder

Finalize configuration options and build a JsonBuilder instance

Trait Implementations§

Source§

impl Default for JsonConfig

Source§

fn default() -> JsonConfig

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.