Skip to main content

Module json_path

Module json_path 

Source
Expand description

JSON key completion for col->'<cursor>' / col->>'<cursor>' chains.

Two sources of keys: same-buffer jsonb literal examples (harvested by a cheap non-parsing scanner), and โ€“ when a live catalog is available โ€“ Column.json_keys recorded for the resolved column. Extracted from engine.rs (was inline there) โ€“ pure code motion, no behavior change.

Functionsยง

json_path_keys_at
When the cursor sits inside the literal of <expr>->'<cursor> or <expr>->>'<cursor>, return the JSON keys observed in same-buffer jsonb literals ('{"key":...}') so the user can autocomplete instead of guessing. Handles chained paths: col->'a'->'b'->'<cursor>' walks into nested objects of the harvested literals and surfaces only the keys present at depth a.b. Returns None outside this context.
json_path_keys_at_with_catalog
Like json_path_keys_at but also consults Column.json_keys from the catalog. When the cursor sits on a col->'...' chain whose head resolves to a known jsonb column with stored top-level keys, surface those even when the buffer has no example literal to harvest.