def leaves
cswap-bend-cli@0.1.0.0 · fmt/shape.bend:179
import cswap-bend-cli@0.1.0.0/fmt/shape.bend as Shape
import Base
import cswap-bend-cli@0.1.0.0/json.bend as Json
179
180def leaves(j: Json.Json, +prefix: String) -> List<&2, Leaf>:
181 match j:
182 case Json.JObj{+f}:
183 leaf.pick(is_empty_obj(f), prefix, leaves(f, prefix))
184 case Json.JField{k, v, +t}:
185 List.append(&2, Leaf, leaves(v, dotted(prefix, k)), leaves(t, prefix))
186 case Json.JNil{}:
187 []
188 case _:
189 Leaf{prefix, cell(j)} <> []