| 100 | } |
| 101 | |
| 102 | void expression_with_params_example() // since 1.3.0 |
| 103 | { |
| 104 | auto doc = json::parse(R"( |
| 105 | { |
| 106 | "results": [ |
| 107 | { |
| 108 | "name": "test1", |
| 109 | "uuid": "33bb9554-c616-42e6-a9c6-88d3bba4221c" |
| 110 | }, |
| 111 | { |
| 112 | "name": "test2", |
| 113 | "uuid": "acde070d-8c4c-4f0d-9d8a-162843c10333" |
| 114 | } |
| 115 | ] |
| 116 | } |
| 117 | )"); |
| 118 | |
| 119 | auto expr = jmespath::make_expression<json>("results[*].[name, uuid, $hostname]"); |
| 120 | |
| 121 | std::map<std::string,json> params = {{"hostname", "localhost"}}; |
| 122 | auto result = expr.evaluate(doc, params); |
| 123 | |
| 124 | auto options = jsoncons::json_options{} |
| 125 | .array_array_line_splits(jsoncons::line_split_kind::same_line); |
| 126 | std::cout << pretty_print(result) << "\n"; |
| 127 | } |
| 128 | |
| 129 | #if defined(_MSC_VER) |
| 130 |
no test coverage detected