Skip to content

Commit

Permalink
custom functions doc
Browse files Browse the repository at this point in the history
  • Loading branch information
danielaparker committed Dec 11, 2024
1 parent b1b779a commit 0241ee7
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 8 deletions.
4 changes: 2 additions & 2 deletions doc/ref/jmespath/jmespath.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ int main()
}
)";

auto expr = jmespath::make_expression<json>("people[?age > `20`].[name, age]"); // since 0.159.0
// auto expr = jmespath::jmespath_expression<json>::compile("people[?age > `20`].[name, age]"); // until 0.159.0
// auto expr = jmespath::jmespath_expression<json>::compile("people[?age > `20`].[name, age]"); // until 0.159.0
auto expr = jmespath::make_expression<json>("people[?age > `20`].[name, age]"); // since 0.159.0

json doc = json::parse(jtext);

Expand Down
19 changes: 16 additions & 3 deletions doc/ref/jmespath/make_expression.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,20 @@
#include <jsoncons_ext/jmespath/jmespath.hpp>

template <typename Json>
jmespath_expression<Json> make_expression(const json::string_view_type& expr); (1)
jmespath_expression<Json> make_expression(const json::string_view_type& expr); (until 1.0.0)
(1)
template <typename Json>
jmespath_expression<Json> make_expression(const Json::string_view_type& expr, (since 1.0.0)
const custom_functions<Json>& funcs = custom_functions<Json>());

template <typename Json>
jmespath_expression<Json> make_expression(const json::string_view_type& expr, (2)
std::error_code& ec);

template <typename Json>
jmespath_expression<Json> make_expression(const json::string_view_type& expr,
std::error_code& ec); (2)
jmespath_expression<Json> make_expression(const Json::string_view_type& expr, (3) (since 1.0.0)
const custom_functions<Json>& funcs,
std::error_code& ec)
```
Returns a compiled JMESPath expression for later evaluation.
Expand All @@ -20,6 +29,10 @@ Returns a compiled JMESPath expression for later evaluation.
<td>expr</td>
<td>JMESPath expression</td>
</tr>
<tr>
<td>funcs</td>
<td>Custom functions</td>
</tr>
<tr>
<td>ec</td>
<td>out-parameter for reporting errors in the non-throwing overload</td>
Expand Down
4 changes: 4 additions & 0 deletions doc/ref/jsonpath/make_expression.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ jsonpath_expression<Json> make_expression(const allocator_set<Json::allocator_ty
<td><code>expr</code></td>
<td>JSONPath expression string</td>
</tr>
<tr>
<td><code>funcs</code></td>
<td>Custom functions</td>
</tr>
<tr>
<td><code>ec</code></td>
<td>out-parameter for reporting errors in the non-throwing overload</td>
Expand Down
6 changes: 3 additions & 3 deletions include/jsoncons_ext/jmespath/jmespath.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5403,21 +5403,21 @@ namespace jmespath {
}

template <typename Json>
jmespath_expression<Json> make_expression(const typename json::string_view_type& expr,
jmespath_expression<Json> make_expression(const typename Json::string_view_type& expr,
const jsoncons::jmespath::custom_functions<Json>& funcs = jsoncons::jmespath::custom_functions<Json>())
{
return jmespath_expression<Json>::compile(expr, funcs);
}

template <typename Json>
jmespath_expression<Json> make_expression(const typename json::string_view_type& expr,
jmespath_expression<Json> make_expression(const typename Json::string_view_type& expr,
std::error_code& ec)
{
return jmespath_expression<Json>::compile(expr, ec);
}

template <typename Json>
jmespath_expression<Json> make_expression(const typename json::string_view_type& expr,
jmespath_expression<Json> make_expression(const typename Json::string_view_type& expr,
const jsoncons::jmespath::custom_functions<Json>& funcs,
std::error_code& ec)
{
Expand Down

0 comments on commit 0241ee7

Please sign in to comment.