mirror of
https://github.com/fluencelabs/jsonpath
synced 2025-04-25 09:22:19 +00:00
25 lines
652 B
Plaintext
25 lines
652 B
Plaintext
|
lua_package_path '/etc/jsonpath/?.lua;;';
|
||
|
|
||
|
error_log /var/log/nginx_error.log info;
|
||
|
|
||
|
server {
|
||
|
listen 80;
|
||
|
server_name localhost;
|
||
|
|
||
|
location / {
|
||
|
default_type text/html;
|
||
|
|
||
|
content_by_lua '
|
||
|
local jsonpath = require("jsonpath")
|
||
|
jsonpath.init("/etc/jsonpath/libjsonpath_lib.so")
|
||
|
local data = ngx.location.capture("/example.json")
|
||
|
local template = jsonpath.compile("$..book[?(@.price<30 && @.category==\'fiction\')]")
|
||
|
local result = template(data.body)
|
||
|
ngx.say(result)
|
||
|
';
|
||
|
}
|
||
|
|
||
|
location /example {
|
||
|
root /etc/jsonpath/example;
|
||
|
}
|
||
|
}
|