use serde_json::Value;

// Remove nulls from a given key's array value.
pub async fn strip_nulls_from_key(root: &mut Value, key: &str) -> Option<Value> {
    let arr: &mut Vec<Value> = root.get_mut(key)?.as_array_mut()?;
    let filtered: Vec<Value> = arr.iter().filter(|v| !v.is_null()).cloned().collect();
    Some(Value::Array(filtered))
}
