pub struct StyleBuilder<'a> { /* private fields */ }
Expand description
Builder to customise path styling
Implementations§
Source§impl<'a> StyleBuilder<'a>
impl<'a> StyleBuilder<'a>
pub fn new() -> Self
Sourcepub fn default_object_key_prefix(self) -> Self
pub fn default_object_key_prefix(self) -> Self
Clears the currently specified object key prefix value
Sourcepub fn object_key_prefix(self, value: &'a str) -> Self
pub fn object_key_prefix(self, value: &'a str) -> Self
Sets the object key prefix value
use serde_json::json;
use json_keypath_iter::{Style, StyleBuilder, Iterator, Element};
let style: Style = StyleBuilder::new()
.object_key_prefix(">>>")
.build();
let value = json!({"apple": [1, true, "three"]});
let iter = Iterator::new(&value).use_style(style);
let items: Vec<_> = iter.collect();
assert_eq!(items[0], Element { path: ">>>apple\"][0]".into(), indices: vec![0], value: &json!(1), });
Sourcepub fn default_object_key_suffix(self) -> Self
pub fn default_object_key_suffix(self) -> Self
Clears the currently specified object key suffix value
Sourcepub fn object_key_suffix(self, value: &'a str) -> Self
pub fn object_key_suffix(self, value: &'a str) -> Self
Sets the object key suffix value
use serde_json::json;
use json_keypath_iter::{Style, StyleBuilder, Iterator, Element};
let style: Style = StyleBuilder::new()
.object_key_suffix("$$$")
.build();
let value = json!({"apple": [1, true, "three"]});
let iter = Iterator::new(&value).use_style(style);
let items: Vec<_> = iter.collect();
assert_eq!(items[0], Element { path: "[\"apple$$$[0]".into(), indices: vec![0], value: &json!(1), });
Sourcepub fn default_object_keys_in_path(self) -> Self
pub fn default_object_keys_in_path(self) -> Self
Clears whether to show or hide object key values in the Element path
Sourcepub fn show_object_keys_in_path(self) -> Self
pub fn show_object_keys_in_path(self) -> Self
Sets the object key values to be visible in the Element path
use serde_json::json;
use json_keypath_iter::{Style, StyleBuilder, Iterator, Element};
let style: Style = StyleBuilder::new()
.show_object_keys_in_path()
.build();
let value = json!({"apple": [1, true, "three"]});
let iter = Iterator::new(&value).use_style(style);
let items: Vec<_> = iter.collect();
assert_eq!(items[0], Element { path: "[\"apple\"][0]".into(), indices: vec![0], value: &json!(1), });
Sourcepub fn hide_object_keys_in_path(self) -> Self
pub fn hide_object_keys_in_path(self) -> Self
Sets the object key values to be hidden in the Element path
use serde_json::json;
use json_keypath_iter::{Style, StyleBuilder, Iterator, Element};
let style: Style = StyleBuilder::new()
.hide_object_keys_in_path()
.build();
let value = json!({"apple": [1, true, "three"]});
let iter = Iterator::new(&value).use_style(style);
let items: Vec<_> = iter.collect();
assert_eq!(items[0], Element { path: "[\"\"][0]".into(), indices: vec![0], value: &json!(1), });
Sourcepub fn default_object_parents(self) -> Self
pub fn default_object_parents(self) -> Self
Clears whether to skip or include values that are objects in the set of yielded values
Sourcepub fn skip_object_parents(self) -> Self
pub fn skip_object_parents(self) -> Self
Sets values that are objects to be yielded by the Iterator
use serde_json::json;
use json_keypath_iter::{Style, StyleBuilder, Iterator, Element};
let style: Style = StyleBuilder::new()
.skip_object_parents()
.build();
let value = json!({"apple": [1, true, "three"]});
let iter = Iterator::new(&value).use_style(style);
let items: Vec<_> = iter.collect();
assert_eq!(items[0], Element { path: "[\"apple\"][0]".into(), indices: vec![0], value: &json!(1), });
Sourcepub fn include_object_parents(self) -> Self
pub fn include_object_parents(self) -> Self
Prevents values that are objects from being yielded by the Iterator
use serde_json::json;
use json_keypath_iter::{Style, StyleBuilder, Iterator, Element};
let style: Style = StyleBuilder::new()
.include_object_parents()
.build();
let value = json!({"apple": [1, true, "three"]});
let iter = Iterator::new(&value).use_style(style);
let items: Vec<_> = iter.collect();
assert_eq!(items[0], Element { path: "".into(), indices: vec![], value: &json!({"apple": [1, true, "three"]}), });
Sourcepub fn default_array_key_prefix(self) -> Self
pub fn default_array_key_prefix(self) -> Self
Clears the currently specified array_key_prefix value
Sourcepub fn array_key_prefix(self, value: &'a str) -> Self
pub fn array_key_prefix(self, value: &'a str) -> Self
Sets the array_key_prefix value
use serde_json::json;
use json_keypath_iter::{Style, StyleBuilder, Iterator, Element};
let style: Style = StyleBuilder::new()
.array_key_prefix(":::")
.build();
let value = json!({"apple": [1, true, "three"]});
let iter = Iterator::new(&value).use_style(style);
let items: Vec<_> = iter.collect();
assert_eq!(items[0], Element { path: "[\"apple\"]:::0]".into(), indices: vec![0], value: &json!(1), });
Sourcepub fn default_array_key_suffix(self) -> Self
pub fn default_array_key_suffix(self) -> Self
Clears the currently specified array key suffix value
Sourcepub fn array_key_suffix(self, value: &'a str) -> Self
pub fn array_key_suffix(self, value: &'a str) -> Self
Sets the array key suffix value
use serde_json::json;
use json_keypath_iter::{Style, StyleBuilder, Iterator, Element};
let style: Style = StyleBuilder::new()
.array_key_suffix("!!!")
.build();
let value = json!({"apple": [1, true, "three"]});
let iter = Iterator::new(&value).use_style(style);
let items: Vec<_> = iter.collect();
assert_eq!(items[0], Element { path: "[\"apple\"][0!!!".into(), indices: vec![0], value: &json!(1), });
Sourcepub fn default_array_keys_in_path(self) -> Self
pub fn default_array_keys_in_path(self) -> Self
Clears whether to show or hide array key values in the Element path
Sourcepub fn show_array_keys_in_path(self) -> Self
pub fn show_array_keys_in_path(self) -> Self
Sets the array key values to be visible in the Element path
use serde_json::json;
use json_keypath_iter::{Style, StyleBuilder, Iterator, Element};
let style: Style = StyleBuilder::new()
.show_array_keys_in_path()
.build();
let value = json!({"apple": [1, true, "three"]});
let iter = Iterator::new(&value).use_style(style);
let items: Vec<_> = iter.collect();
assert_eq!(items[0], Element { path: "[\"apple\"][0]".into(), indices: vec![0], value: &json!(1), });
Sourcepub fn hide_array_keys_in_path(self) -> Self
pub fn hide_array_keys_in_path(self) -> Self
Sets the array key values to be hidden in the Element path
use serde_json::json;
use json_keypath_iter::{Style, StyleBuilder, Iterator, Element};
let style: Style = StyleBuilder::new()
.hide_array_keys_in_path()
.build();
let value = json!({"apple": [1, true, "three"]});
let iter = Iterator::new(&value).use_style(style);
let items: Vec<_> = iter.collect();
assert_eq!(items[0], Element { path: "[\"apple\"][]".into(), indices: vec![0], value: &json!(1), });
Sourcepub fn default_array_parents(self) -> Self
pub fn default_array_parents(self) -> Self
Clears whether to skip or include values that are arrays in the set of yielded values
Sourcepub fn skip_array_parents(self) -> Self
pub fn skip_array_parents(self) -> Self
Sets values that are arrays to be yielded by the Iterator
use serde_json::json;
use json_keypath_iter::{Style, StyleBuilder, Iterator, Element};
let style: Style = StyleBuilder::new()
.skip_array_parents()
.build();
let value = json!({"apple": [1, true, "three"]});
let iter = Iterator::new(&value).use_style(style);
let items: Vec<_> = iter.collect();
assert_eq!(items[0], Element { path: "[\"apple\"][0]".into(), indices: vec![0], value: &json!(1), });
Sourcepub fn include_array_parents(self) -> Self
pub fn include_array_parents(self) -> Self
Prevents values that are arrays from being yielded by the Iterator
use serde_json::json;
use json_keypath_iter::{Style, StyleBuilder, Iterator, Element};
let style: Style = StyleBuilder::new()
.include_array_parents()
.build();
let value = json!({"apple": [1, true, "three"]});
let iter = Iterator::new(&value).use_style(style);
let items: Vec<_> = iter.collect();
assert_eq!(items[0], Element { path: "[\"apple\"]".into(), indices: vec![], value: &json!([1, true, "three"]), });