1
0
mirror of https://github.com/fluencelabs/jsonpath synced 2025-04-11 19:16:04 +00:00

23 lines
531 B
Lua
Raw Normal View History

2019-08-23 22:09:09 +09:00
local jsonpath = require("jsonpath")
2019-08-23 00:00:01 +09:00
local iter;
if arg[1] == nil or arg[1] == '' then
iter = 5000;
else
iter = tonumber(arg[1]);
end
print(string.format("%s - %u", "lua iter", iter));
2019-08-23 22:09:09 +09:00
local file = io.open("../../benchmark/example.json", "r");
2019-08-23 00:00:01 +09:00
io.input(file)
local data = io.read("*a");
io.close(file);
2019-08-23 22:09:09 +09:00
jsonpath.init('../target/release/deps/libjsonpath_lib.so')
local template = jsonpath.compile("$..book[?(@.price<30 && @.category==\"fiction\")]");
2019-08-23 00:00:01 +09:00
for i = 0, iter do
2019-08-23 11:53:03 +09:00
local r = template(data);
2019-08-23 00:00:01 +09:00
-- print(r);
end