NeoGraph 0.10.0
A C++17 Graph Agent Engine Library — LangGraph for C++
Loading...
Searching...
No Matches
json_path.h File Reference

JSON dot-path navigation utilities. More...

#include <neograph/json.h>
#include <optional>
#include <string>
#include <vector>
Include dependency graph for json_path.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

std::optional< json > neograph::llm::json_path::at_path (const json &root, const std::string &path)
 Navigate into root by dot-path. Returns nullopt if path doesn't resolve.
 
template<typename T >
neograph::llm::json_path::get_path (const json &root, const std::string &path, const T &default_val)
 Fetch value at path or return default_val on missing/wrong-type.
 
bool neograph::llm::json_path::has_path (const json &root, const std::string &path)
 True if path exists in root.
 
bool neograph::llm::json_path::is_index (const std::string &s)
 True if every char is a digit.
 
void neograph::llm::json_path::set_path (json &root, const std::string &path, const json &value)
 Set value at path, creating intermediate objects as needed.
 
std::vector< std::string > neograph::llm::json_path::split_path (const std::string &path)
 Split "a.b.0.c" into ["a","b","0","c"].
 

Detailed Description

JSON dot-path navigation utilities.

Provides functions for navigating and manipulating JSON objects using dot-notation paths like "choices.0.message.content". Numeric segments are treated as array indices.

Unlike the prior nlohmann-based version (which returned raw const json* pointers into the parent document), these functions return std::optional<json> since our yyjson-backed handles are lightweight value types sharing the underlying document via shared_ptr.

Definition in file json_path.h.