Skip to main content

navigate_json_path

Function navigate_json_path 

Source
pub fn navigate_json_path(value: &Value, path: &str) -> Result<Value>
Expand description

Navigate to a sub-value of a JSON document using a dotted path.

This is the shared “find the rows” step used by both the WEB CTE JSON_PATH clause and READ_JSON(path, json_path). It only locates a value; it deliberately does not filter, transform, or pluck scalars — that is SQL’s job (use a WHERE clause / column list once the rows are loaded). Anything beyond locating the row set is out of scope; pipe through jq.

Supports two forms per dotted segment:

  • name — descend into an object key
  • name[] — descend into name (must be an array), then map the remainder of the path across every element. A bare [] projects over the current value when it is already an array.

Example for an Elasticsearch response: hits.hits[]._source returns an array of _source objects, one per hit — i.e. the _source fields become the top-level row shape consumed by the loader.

An empty path (or one that is only dots) returns the value unchanged.