get_nested_value

Function get_nested_value 

Source
pub fn get_nested_value<'b>(data: &'b Value, path: &str) -> Option<&'b Value>
Expand description

Get nested value from JSON using dot notation path

Supports both object property access and array indexing:

  • "user.name" - Access object property
  • "items.0" - Access array element by index
  • "user.addresses.0.city" - Combined object and array access
  • "data.#20" - Access field named “20” (# prefix removed)
  • "data.##" - Access field named “#” (first # removed, second # kept)

§Arguments

  • data - The JSON value to navigate
  • path - Dot-separated path to the target value

§Returns

  • Option<&Value> - Reference to the value if found, None otherwise

§Safety

Returns None for invalid array indices or missing keys rather than panicking