Skip to main content

drop_empty_recursive

Function drop_empty_recursive 

Source
pub fn drop_empty_recursive(v: Value) -> Value
Expand description

Recursive variant of drop_empty_top_level. Walks every nested object and drops null/[]/{} children. Arrays’ elements are recursed into (an object inside an array still gets cleaned) but the array itself is preserved at its length — position often matters in arrays.

AcmeFlow refinement #1 (1.0.84): applied selectively to safe_change_recipe in prepare-change responses. Without this, safe_change_recipe.preserve:[], reference_only:[], likely_omitted_files:[] etc. bloat the response on the common case where the recipe has nothing to preserve / nothing reference-only / nothing omitted.

Use sparingly outside of known-noisy subtrees — an empty array inside a less-known object COULD be load-bearing semantics (“explicit empty list” vs “no list”). For shapes you control and know to be noise, this is the right tool.