Struct chisel_json::paths::JsonPath
source · pub struct JsonPath<'a> { /* private fields */ }
Expand description
Struct for creating and manipulating Json paths vaguely compatible with a subset of RFC 8259. Each instance of JsonPath comprises of multiple JsonPathComponents
Implementations§
source§impl<'a> JsonPath<'a>
impl<'a> JsonPath<'a>
sourcepub fn new_partial() -> Self
pub fn new_partial() -> Self
Create a new, partial (no root) JsonPath instance
sourcepub fn is_partial(&self) -> bool
pub fn is_partial(&self) -> bool
A partial path doesn’t have a JsonPathComponent::Root in the first position
sourcepub fn push_str_selector(&mut self, name: &str)
pub fn push_str_selector(&mut self, name: &str)
Push a new JsonPathComponent::NameSelector based on a string slice. Note that no validation is carried out (as of yet) to check whether the name is actually valid and not full of crap
sourcepub fn push_index_select(&mut self, index: usize)
pub fn push_index_select(&mut self, index: usize)
Push a new JsonPathComponent::IndexSelector based on a given index
sourcepub fn push_range_selector(&mut self, start: usize, end: usize)
pub fn push_range_selector(&mut self, start: usize, end: usize)
Push a new JsonPathComponent::RangeSelector based on a given start and end index
sourcepub fn push_wildcard_selector(&mut self)
pub fn push_wildcard_selector(&mut self)
Push a new JsonPathComponent::WildcardSelector
sourcepub fn push(&mut self, component: JsonPathComponent<'a>)
pub fn push(&mut self, component: JsonPathComponent<'a>)
Appends a new JsonPathComponent to the end of the path
sourcepub fn pop(&mut self) -> Option<JsonPathComponent<'a>>
pub fn pop(&mut self) -> Option<JsonPathComponent<'a>>
Pops the last JsonPathComponent from the end of the path (if it exists)
sourcepub fn is_array_path(&self) -> bool
pub fn is_array_path(&self) -> bool
Checks whether a path points to an array element within the source JSON