pub fn query_first(
doc: &Document,
path: &str,
config: &QueryConfig,
) -> QueryResult<Option<Value>>Expand description
Query a HEDL document and return the first match
Convenience function for queries expected to return a single result.
§Arguments
doc- The HEDL document to querypath-JSONPathexpressionconfig- Query configuration
§Returns
The first matching JSON value, or None if no matches found
§Examples
use hedl_json::jsonpath::{query_first, QueryConfig};
use hedl_core::Document;
# fn example() -> Result<(), Box<dyn std::error::Error>> {
let doc = hedl_core::parse_hedl("name: \"Alice\""?;
let config = QueryConfig::default();
let result = query_first(&doc, "$.name", &config)?;
assert!(result.is_some());
# Ok(())
# }