Skip to content
This repository was archived by the owner on Feb 11, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.rocks
.idea
luaunit
10 changes: 10 additions & 0 deletions .luacheckrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
std = {
read_globals = {'box', 'require', 'debug', 'pcall', 'xpcall', 'tostring',
'tonumber', 'type', 'assert', 'ipairs', 'math', 'error', 'string',
'table', 'pairs', 'os', 'io', 'select', 'unpack', 'dofile', 'next',
'loadstring', 'setfenv', 'print',
'getmetatable', 'setmetatable', 'SCRIPT_PATH'
},
globals = {'process_request', 'package'}
}
redefined = False
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.PHONY: lint
lint:
luacheck --config=.luacheckrc --no-unused-args --no-redefined \
jsonpath.lua

.PHONY: test
test: build lint
./test/test.lua

.PHONY: build
build:
tarantoolctl rocks make

all: build test
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Query Lua data structures with JsonPath expressions. Robust and safe JsonPath en

This library implements Stefan Goessner's [JsonPath syntax](http://goessner.net/articles/JsonPath/) in Lua. Lua JsonPath is compatible with David Chester's [Javascript implementation](https://github.com/dchester/jsonpath).

The JsonPath Lua library was written from scratch by Frank Edelhaeuser. It's a pure Lua implementation based on a PEG grammer handled by Roberto Ierusalimschy's fabulous [LPeg pattern-matching library](http://www.inf.puc-rio.br/~roberto/lpeg/lpeg.html).
The JsonPath Lua library was written from scratch by Frank Edelhaeuser. It's a pure Lua implementation based on a PEG grammer handled by [LulPeg pattern-matching library](https://github.com/pygy/LuLPeg).

Some of this README and a subset of test cases were adopted from David Chester's [Javascript implementation](https://github.com/dchester/jsonpath) which is based on Stefan Goessner's [original work](http://goessner.net/articles/JsonPath/).

Expand Down Expand Up @@ -188,8 +188,8 @@ Provides the lua-jsonpath LPEG grammer for embedding in higher level LPEG gramme
The abstract syntax tree matched for JsonPath elementes in a higher level LPEG grammer can then be supplied to `jp.nodes()`, `jp.paths()` or `jp.query()` instead of the string `pathExpression`.

```lua
local lpeg = require('lpeg')
local assignment = lpeg.C(lpeg.R'az') * lpeg.P'=' * lpeg.P'"' * jp.grammer() * lpeg.P'"'
local lulpeg = require('lulpeg')
local assignment = lulpeg.C(lulpeg.R'az') * lulpeg.P'=' * lulpeg.P'"' * jp.grammer() * lulpeg.P'"'
local var, ast = assignment:match('x="$..author"')
-- var = 'x'
local results = jp.query(data, ast)
Expand Down Expand Up @@ -237,7 +237,7 @@ Some of David Chester's API methods are not implemented in Lua JsonPath:

The `jp.value` API method does not support the third argument (`newValue`).

The `jp.grammer` API method was added in Lua JsonPath. The `jp.query`, `jp.value`, `jp.paths`, `jp.nodes` functions accept abstract syntax trees returned by `lpeg.match` for Lua JsonPath expressions matched using `jp.grammer`. This is for embedding Lua JsonPath into higher level grammers.
The `jp.grammer` API method was added in Lua JsonPath. The `jp.query`, `jp.value`, `jp.paths`, `jp.nodes` functions accept abstract syntax trees returned by `lulpeg.match` for Lua JsonPath expressions matched using `jp.grammer`. This is for embedding Lua JsonPath into higher level grammers.


## License
Expand Down
11 changes: 4 additions & 7 deletions jsonpath-1.0-1.rockspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package = 'jsonpath'
version = '1.0-1'
source = {
url = 'git://github.com/mrpace2/lua-jsonpath',
url = 'git://github.com/tarantool/lua-jsonpath',
tag = '1.0'
}
description = {
Expand All @@ -11,21 +11,18 @@ This library implements Stefan Goessner's JsonPath syntax (http://goessner.net/a

Lua JsonPath is compatible with David Chester's Javascript implementation (https://github.com/dchester/jsonpath).

The Lua JsonPath library was written from scratch by Frank Edelhaeuser. It's a pure Lua implementation based on a PEG grammer handled by Roberto Ierusalimschy's fabulous LPeg pattern-matching library (http://www.inf.puc-rio.br/~roberto/lpeg/lpeg.html).
The Lua JsonPath library was written from scratch by Frank Edelhaeuser. It's a pure Lua implementation based on a PEG grammer handled by LulPeg pattern-matching library (https://github.com/pygy/LuLPeg.git).
]],
homepage = 'https://github.com/mrpace2/lua-jsonpath',
homepage = 'https://github.com/tarantool/lua-jsonpath',
license = 'MIT'
}
dependencies = {
'lua >= 5.1',
'lpeg >= 1.0.0'
'lulpeg'
}
build = {
type = 'builtin',
modules = {
jsonpath = 'jsonpath.lua'
},
copy_directories = {
'test'
}
}
Loading