MCPcopy Create free account
hub / github.com/erans/pgsqlite / strip_nulls

Function strip_nulls

src/functions/json_functions.rs:1509–1525  ·  view source on GitHub ↗

Remove null values from JSON

(json: &JsonValue)

Source from the content-addressed store, hash-verified

1507
1508/// Remove null values from JSON
1509fn strip_nulls(json: &JsonValue) -> JsonValue {
1510 match json {
1511 JsonValue::Object(map) => {
1512 let mut new_map = serde_json::Map::new();
1513 for (key, value) in map {
1514 if !value.is_null() {
1515 new_map.insert(key.clone(), strip_nulls(value));
1516 }
1517 }
1518 JsonValue::Object(new_map)
1519 }
1520 JsonValue::Array(arr) => {
1521 JsonValue::Array(arr.iter().map(strip_nulls).collect())
1522 }
1523 _ => json.clone(),
1524 }
1525}
1526
1527/// Check if container JSON contains the contained JSON
1528fn json_contains(container: &JsonValue, contained: &JsonValue) -> bool {

Callers 1

register_json_functionsFunction · 0.85

Calls 2

insertMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected