Struct flatten_json_object::Flattener
source · [−]pub struct Flattener { /* private fields */ }
Expand description
Basic struct of this crate. It contains the configuration. Instantiate it and use the method
flatten
to flatten a JSON object.
Implementations
sourceimpl Flattener
impl Flattener
sourcepub fn set_key_separator(self, key_separator: &str) -> Self
pub fn set_key_separator(self, key_separator: &str) -> Self
Changes the string used to separate keys in the resulting flattened object.
sourcepub fn set_array_formatting(self, array_formatting: ArrayFormatting) -> Self
pub fn set_array_formatting(self, array_formatting: ArrayFormatting) -> Self
Changes the way arrays are formatted. By default the position in the array is treated as a normal key, but with this function we can change this behaviour.
sourcepub fn set_preserve_empty_arrays(self, value: bool) -> Self
pub fn set_preserve_empty_arrays(self, value: bool) -> Self
Changes the behaviour regarding empty arrays []
sourcepub fn set_preserve_empty_objects(self, value: bool) -> Self
pub fn set_preserve_empty_objects(self, value: bool) -> Self
Changes the behaviour regarding empty objects {}
pub fn key_separator(&self) -> &str
pub fn array_formatting(&self) -> &ArrayFormatting
pub fn preserve_empty_arrays(&self) -> bool
pub fn preserve_empty_objects(&self) -> bool
sourcepub fn flatten(&self, to_flatten: &Value) -> Result<Value, Error>
pub fn flatten(&self, to_flatten: &Value) -> Result<Value, Error>
Flattens the provided JSON object (current
).
It will return an error if flattening the object would make two keys to be the same, overwriting a value. It will alre return an error if the JSON value passed it’s not an object.
Errors
Will return Err
if to_flatten
it’s not an object, or if flattening the object would
result in two or more keys colliding.
Trait Implementations
impl Eq for Flattener
impl StructuralEq for Flattener
impl StructuralPartialEq for Flattener
Auto Trait Implementations
impl RefUnwindSafe for Flattener
impl Send for Flattener
impl Sync for Flattener
impl Unpin for Flattener
impl UnwindSafe for Flattener
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more