Switch the get_loop_elements implementation to only return populated arrays when its an array-like object.
This commit is contained in:
26
src/bin.rs
26
src/bin.rs
@@ -294,30 +294,8 @@ impl Walkable for serde_json::Value {
|
||||
impl Loopable for serde_json::Value {
|
||||
fn get_loop_elements(&self) -> Vec<&dyn ContextElement> {
|
||||
match self {
|
||||
serde_json::Value::Null => Vec::new(),
|
||||
serde_json::Value::Bool(boolean) => {
|
||||
if *boolean {
|
||||
vec![self]
|
||||
} else {
|
||||
Vec::new()
|
||||
}
|
||||
}
|
||||
serde_json::Value::Number(_num) => vec![self],
|
||||
serde_json::Value::String(string_value) => {
|
||||
if string_value.is_empty() {
|
||||
Vec::new()
|
||||
} else {
|
||||
vec![self]
|
||||
}
|
||||
}
|
||||
serde_json::Value::Array(array_value) => {
|
||||
if array_value.is_empty() {
|
||||
Vec::new()
|
||||
} else {
|
||||
array_value.iter().map(|x| x as _).collect()
|
||||
}
|
||||
}
|
||||
serde_json::Value::Object(_obj) => vec![self],
|
||||
serde_json::Value::Array(array_value) => array_value.iter().map(|x| x as _).collect(),
|
||||
_ => Vec::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user