Slice support for glz::read_jmespath
std::vector<int> data{0,1,2,3,4,5,6,7,8,9};
std::string buffer{};
expect(not glz::write_json(data, buffer));
std::vector<int> slice{};
expect(not glz::read_jmespath<"[0:5]">(slice, buffer));
expect(slice.size() == 5);
expect(slice[0] == 0);
expect(slice[1] == 1);
expect(slice[2] == 2);
expect(slice[3] == 3);
expect(slice[4] == 4);
Pre-compute JMESPath run-time expressions
The run-time version of glz::read_jmespath
also now takes in a const jmespath_expression&
. This allows a jmespath_expression
to be "compiled" once in the code and reused for much better runtime performance. This caches the tokenization.
Person child{};
// A runtime expression can be pre-computed and saved for more efficient lookups
glz::jmespath_expression expression{"family.children[0]"};
expect(not glz::read_jmespath(expression, child, buffer));
expect(child.first_name == "Lilly");
Note that this still works:
expect(not glz::read_jmespath("family.children[0]", child, buffer));
by @stephenberry in #1510
Fixes
Full Changelog: v4.2.1...v4.2.2