pub trait JsonLike:
Default
+ Clone
+ Debug
+ for<'a> From<&'a str>
+ From<Vec<String>>
+ From<bool>
+ From<i64>
+ From<f64>
+ From<Vec<Self>>
+ From<String>
+ PartialEq
+ 'static {
Show 18 methods
// Required methods
fn get(&self, key: &str) -> Option<&Self>;
fn itre(&self, pref: String) -> Vec<JsonPathValue<'_, Self>>;
fn array_len(&self) -> JsonPathValue<'static, Self>;
fn init_with_usize(cnt: usize) -> Self;
fn deep_flatten(&self, pref: String) -> Vec<(&Self, String)>;
fn deep_path_by_key<'a>(
&'a self,
key: ObjectField<'a, Self>,
pref: String,
) -> Vec<(&'a Self, String)>;
fn as_u64(&self) -> Option<u64>;
fn is_array(&self) -> bool;
fn as_array(&self) -> Option<&Vec<Self>>;
fn size(left: Vec<&Self>, right: Vec<&Self>) -> bool;
fn sub_set_of(left: Vec<&Self>, right: Vec<&Self>) -> bool;
fn any_of(left: Vec<&Self>, right: Vec<&Self>) -> bool;
fn regex(left: Vec<&Self>, right: Vec<&Self>) -> bool;
fn inside(left: Vec<&Self>, right: Vec<&Self>) -> bool;
fn less(left: Vec<&Self>, right: Vec<&Self>) -> bool;
fn eq(left: Vec<&Self>, right: Vec<&Self>) -> bool;
fn null() -> Self;
fn array(data: Vec<Self>) -> Self;
}
Expand description
The JsonLike
trait defines a set of methods and associated types for working with JSON-like data structures.
It provides a common interface for accessing and manipulating JSON data, allowing for operations such as
- retrieving values by key,
- iterating over elements
- performing various comparisons and transformations.
The trait is implemented for the serde_json::Value
type already
Required Methods§
sourcefn get(&self, key: &str) -> Option<&Self>
fn get(&self, key: &str) -> Option<&Self>
Retrieves a reference to the value associated with the given key.
sourcefn itre(&self, pref: String) -> Vec<JsonPathValue<'_, Self>>
fn itre(&self, pref: String) -> Vec<JsonPathValue<'_, Self>>
Iterates over the elements with a given prefix and returns a vector of JsonPathValue
.
sourcefn array_len(&self) -> JsonPathValue<'static, Self>
fn array_len(&self) -> JsonPathValue<'static, Self>
Returns the length of the array as a JsonPathValue
.
sourcefn init_with_usize(cnt: usize) -> Self
fn init_with_usize(cnt: usize) -> Self
Initializes an instance with a specific size.
sourcefn deep_flatten(&self, pref: String) -> Vec<(&Self, String)>
fn deep_flatten(&self, pref: String) -> Vec<(&Self, String)>
Flattens nested structures and returns a vector of tuples containing references to the elements and their paths.
sourcefn deep_path_by_key<'a>(
&'a self,
key: ObjectField<'a, Self>,
pref: String,
) -> Vec<(&'a Self, String)>
fn deep_path_by_key<'a>( &'a self, key: ObjectField<'a, Self>, pref: String, ) -> Vec<(&'a Self, String)>
Performs a deep search by key and returns a vector of tuples containing references to the elements and their paths.
sourcefn size(left: Vec<&Self>, right: Vec<&Self>) -> bool
fn size(left: Vec<&Self>, right: Vec<&Self>) -> bool
Compares the size of two vectors of references to elements.
sourcefn sub_set_of(left: Vec<&Self>, right: Vec<&Self>) -> bool
fn sub_set_of(left: Vec<&Self>, right: Vec<&Self>) -> bool
Checks if the left vector is a subset of the right vector.
sourcefn any_of(left: Vec<&Self>, right: Vec<&Self>) -> bool
fn any_of(left: Vec<&Self>, right: Vec<&Self>) -> bool
Checks if any element in the left vector is present in the right vector.
sourcefn regex(left: Vec<&Self>, right: Vec<&Self>) -> bool
fn regex(left: Vec<&Self>, right: Vec<&Self>) -> bool
Checks if the elements in the left vector match the regex pattern in the right vector.
sourcefn inside(left: Vec<&Self>, right: Vec<&Self>) -> bool
fn inside(left: Vec<&Self>, right: Vec<&Self>) -> bool
Checks if any element in the left vector is inside the right vector.
Object Safety§
Implementations on Foreign Types§
source§impl JsonLike for Value
impl JsonLike for Value
source§fn less(left: Vec<&Self>, right: Vec<&Self>) -> bool
fn less(left: Vec<&Self>, right: Vec<&Self>) -> bool
ensure the number on the left side is less the number on the right side