Skip to content

Latest commit

 

History

History
82 lines (63 loc) · 2.42 KB

jsonpath_expression.md

File metadata and controls

82 lines (63 loc) · 2.42 KB

jsoncons::jsonpath::jsonpath_expression

#include <jsoncons_ext/jsonpath/jsonpath.hpp>

template <class Json,class JsonReference>
class jsonpath_expression

Member functions

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.

Parameters

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 functions

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.

Parameters

expr JSONPath expression
ec out-parameter for reporting errors in the non-throwing overload

Exceptions

(1) Throws a jsonpath_error if JSONPath compilation fails.

(2) Sets the out-parameter ec to the jsonpath_error_category if JSONPath compilation fails.