strip

Function strip 

Source
pub fn strip(mask: BitFlags<Strip, u8>, value: Value) -> Option<Value>
Expand description

Strips the provided value of specified Strip enum type.

Note: This does NOT remove nulls inside arrays unless ALL are null and the Strip Null | Empties options are set due to the potential for re-ordering indexes where each may have a specific meaning.

use json_plus::{strip, Strip};
use serde_json::json;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let base = json!({"key":"old value", "null":null, "empty":[]});

    let stripped = strip(Strip::Nulls | Strip::Empties, base).unwrap();
    println!("{}", stripped.to_string());
    Ok(())
}