Function remove_empty_value

Source
pub fn remove_empty_value<I>(entries: I) -> BTreeMap<String, Value>
where I: IntoIterator<Item = (String, Value)>,
Expand description

Removes entries with empty or null values from an iterator of key-value pairs.

§Arguments

  • entries - An iterator of key-value pairs where keys are strings and values are of type Value.

§Returns

A BTreeMap containing only the key-value pairs where the value is neither null nor an empty string.

§Examples

let entries = vec![ (“key1".to_string(), Value::String("value1".to_string())), (”key2".to_string(), Value::Null), (“key3".to_string(), Value::String("".to_string())), ]; let filtered = remove_empty_value(entries); // filtered will only contain the first key-value pair