extract

fun extract(document: Variant, sink: (pathIndex: Int, element: Variant) -> Unit)

Reports every (pathIndex, element) this document holds.

A path may be reported many times — $.items[*] over three items reports three elements — and the elements arrive in document order, which is what makes a per-element predicate's answer independent of how the walk is implemented.

A path landing on a scalar reports nothing, and neither does one landing on nothing at all. Same rule as Variant.select: "this document has nothing there" is an answer.

The element is a view over bytes valid only for the duration of the call; anything kept must be copied.