#include <jsoncons_ext/jsonpath/jsonpath.hpp>
template <class Json,class JsonReference>
class jsonpath_expression
Json evaluate(reference root_value, result_options options = result_options()); (1)
template <class BinaryCallback>
void evaluate(reference root_value, BinaryCallback callback,
result_options options = result_options()); (2)
(1) Evaluates the root value against the compiled JSONPath expression and returns an array of values or normalized path expressions.
(2) Evaluates the root value against the compiled JSONPath expression and calls a provided callback repeatedly with the results.
root_value | JSON value |
callback |
A function object that accepts a path and a reference to a Json value.
It must have function call signature equivalent to
void fun(const Json::string_type& path, const Json& val);
|
result_options | Result options, a bitmask of type result_options |
static jsonpath_expression compile(const string_view_type& expr); (1)
static jsonpath_expression compile(const string_view_type& expr,
const custom_functions<Json>& funcs); (2) (since 0.164.0)
static jsonpath_expression compile(const string_view_type& expr,
std::error_code& ec); (3)
static jsonpath_expression compile(const string_view_type& expr,
const custom_functions<Json>& funcs,
std::error_code& ec); (4) (since 0.164.0)
Compiles the JSONPath expression for later evaluation. Returns a jsonpath_expression
object
that represents the JSONPath expression.
expr | JSONPath expression |
ec | out-parameter for reporting errors in the non-throwing overload |
(1) Throws a jsonpath_error if JSONPath compilation fails.
(2) Sets the out-parameter ec
to the jsonpath_error_category if JSONPath compilation fails.