jsonpath 0.8.7 → 0.8.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -1
- data/lib/jsonpath/parser.rb +2 -2
- data/lib/jsonpath/version.rb +1 -1
- data/test/test_jsonpath.rb +50 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 401aa3e206ffa2419b6d577e09e721a5d2a0eb5d
|
4
|
+
data.tar.gz: 2fbf9f702bd048b551b494768c31a0e9aef8c361
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2bba3a7ff2c1e8cde53b60fdc49ab579e55eb7064a059a2f5c622088bbadc304db26741c371aa46a3e97a1e6d85e6a942ccd8f3727ca0522972d094f41f72e0
|
7
|
+
data.tar.gz: ace0993e371d6365967652e3e8240860a197e736c8f91870341bed2163e940fcc0035ad91598a7581bb0285408c2250c3488890eeb1b722060bf6a0de9ee3495
|
data/.travis.yml
CHANGED
data/lib/jsonpath/parser.rb
CHANGED
@@ -22,7 +22,7 @@ class JsonPath
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def parse_exp(exp)
|
25
|
-
exp = exp.
|
25
|
+
exp = exp.sub(/@/, '').gsub(/[\(\)]/, '').gsub(/"/, '\'').strip
|
26
26
|
scanner = StringScanner.new(exp)
|
27
27
|
elements = []
|
28
28
|
until scanner.eos?
|
@@ -32,7 +32,7 @@ class JsonPath
|
|
32
32
|
num = scanner.scan(/\d+/)
|
33
33
|
return @_current_node.send(sym.to_sym).send(op.to_sym, num.to_i)
|
34
34
|
end
|
35
|
-
if t = scanner.scan(/\['
|
35
|
+
if t = scanner.scan(/\['[a-zA-Z@&\*\/\$%\^\?]+'\]+/)
|
36
36
|
elements << t.gsub(/\[|\]|'|\s+/, '')
|
37
37
|
elsif t = scanner.scan(/(\s+)?[<>=][<>=]?(\s+)?/)
|
38
38
|
operator = t
|
data/lib/jsonpath/version.rb
CHANGED
data/test/test_jsonpath.rb
CHANGED
@@ -295,6 +295,56 @@ class TestJsonpath < MiniTest::Unit::TestCase
|
|
295
295
|
assert_equal([{"type"=>"users", "id"=>"123"}], JsonPath.new("$.foo[?(@.id == '123')]").on(data))
|
296
296
|
end
|
297
297
|
|
298
|
+
def test_at_in_filter
|
299
|
+
jsonld = {
|
300
|
+
"mentions" => [
|
301
|
+
{
|
302
|
+
"name" => "Delimara Powerplant",
|
303
|
+
"identifier" => "krzana://took/powerstation/Delimara Powerplant",
|
304
|
+
"@type" => "Place",
|
305
|
+
"geo" => {
|
306
|
+
"latitude" => 35.83020073454,
|
307
|
+
"longitude" => 14.55602645874
|
308
|
+
}
|
309
|
+
}
|
310
|
+
]
|
311
|
+
}
|
312
|
+
assert_equal(['Place'], JsonPath.new("$..mentions[?(@['@type'] == 'Place')].@type").on(jsonld))
|
313
|
+
end
|
314
|
+
|
315
|
+
def test_dollar_in_filter
|
316
|
+
jsonld = {
|
317
|
+
"mentions" => [
|
318
|
+
{
|
319
|
+
"name" => "Delimara Powerplant",
|
320
|
+
"identifier" => "krzana://took/powerstation/Delimara Powerplant",
|
321
|
+
"$type" => "Place",
|
322
|
+
"geo" => {
|
323
|
+
"latitude" => 35.83020073454,
|
324
|
+
"longitude" => 14.55602645874
|
325
|
+
}
|
326
|
+
}
|
327
|
+
]
|
328
|
+
}
|
329
|
+
assert_equal(['Place'], JsonPath.new("$..mentions[?(@['$type'] == 'Place')].$type").on(jsonld))
|
330
|
+
end
|
331
|
+
|
332
|
+
def test_at_in_value
|
333
|
+
jsonld = {
|
334
|
+
"mentions" =>
|
335
|
+
{
|
336
|
+
"name" => "Delimara Powerplant",
|
337
|
+
"identifier" => "krzana://took/powerstation/Delimara Powerplant",
|
338
|
+
"type" => "@Place",
|
339
|
+
"geo" => {
|
340
|
+
"latitude" => 35.83020073454,
|
341
|
+
"longitude" => 14.55602645874
|
342
|
+
}
|
343
|
+
}
|
344
|
+
}
|
345
|
+
assert_equal(['@Place'], JsonPath.new("$..mentions.type[?(@ == '@Place')]").on(jsonld))
|
346
|
+
end
|
347
|
+
|
298
348
|
def example_object
|
299
349
|
{ 'store' => {
|
300
350
|
'book' => [
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jsonpath
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joshua Hull
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-10-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: multi_json
|