Skip to main content

map_obj

Function map_obj 

Source
pub fn map_obj<F>(object: &Value, deep: bool, mapper: F) -> Value
where F: FnMut(&str, &Value) -> MapEntry,
Expand description

Map over the keys and values of object.

mapper is called with each (key, value) and returns a MapEntry. With deep, the mapper is also applied to nested objects (and to objects inside arrays). Keys mapped to __proto__ are dropped, matching the reference.

Non-object input is returned unchanged (the JavaScript original instead throws; this is the lenient Rust equivalent).