private static Json5Value Walk(Json5Container holder, string key, Func <Json5Container, string, Json5Value, Json5Value> transformer) { Json5Value value = holder[key]; if (value is Json5Container) { Json5Container c = (Json5Container)value; string[] keys = c.Keys.ToArray(); foreach (string k in keys) { Json5Value v = Walk(c, k, transformer); if (v != null) { c[k] = v; } else { c.Remove(k); } } } // Special case for holder if (key == "") { return(value); } return(transformer(holder, key, value)); }
private static Json5Value Walk(Json5Container holder, string key, Func <Json5Container, string, Json5Value, Json5Value> transformer) { Json5Value value = holder[key]; if (value is Json5Container) { Json5Container c = (Json5Container)value; foreach (string k in c.Keys) { Json5Value v = Walk(c, k, transformer); if (v != null) { c[k] = v; } else { c.Remove(k); } } } return(transformer(holder, key, value)); }