jsonpath 0.8.8 → 0.8.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/jsonpath/parser.rb +2 -2
- data/lib/jsonpath/version.rb +1 -1
- data/test/test_jsonpath.rb +24 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ccfcb77f1e1d53075429a1de02a47582533adaa
|
4
|
+
data.tar.gz: df31c7f7e048956e4377c15102dbace9427e9a50
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 525c8cff304cb529977edc935a2c2a8163b632a1e7290cef4b7ea73d80cb1c20a228ea18e545023231367c3255a74a5183a9f854c7b147877ff6cea9e5f716e5
|
7
|
+
data.tar.gz: 0dc3e440ba55497515f40b82d594beef82f70e495d20f658d839cb1ce2a757d626756bb0ce59aad526c3b0089b245769926875e257b67b93d625a5330039ba1c
|
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.sub(/@/, '').gsub(
|
25
|
+
exp = exp.sub(/@/, '').gsub(/^\(/, '').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(/\['[a-zA-Z@&\*\/\$%\^\?]+'\]+/)
|
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
@@ -329,6 +329,20 @@ class TestJsonpath < MiniTest::Unit::TestCase
|
|
329
329
|
assert_equal(['Place'], JsonPath.new("$..mentions[?(@['$type'] == 'Place')].$type").on(jsonld))
|
330
330
|
end
|
331
331
|
|
332
|
+
def test_underscore_in_filter
|
333
|
+
jsonld = {
|
334
|
+
"attributes" => [
|
335
|
+
{
|
336
|
+
"store" => [
|
337
|
+
{ "with" => "urn" },
|
338
|
+
{ "with_underscore" => "urn:1" }
|
339
|
+
]
|
340
|
+
}
|
341
|
+
]
|
342
|
+
}
|
343
|
+
assert_equal(['urn:1'], JsonPath.new("$.attributes..store[?(@['with_underscore'] == 'urn:1')].with_underscore").on(jsonld))
|
344
|
+
end
|
345
|
+
|
332
346
|
def test_at_in_value
|
333
347
|
jsonld = {
|
334
348
|
"mentions" =>
|
@@ -343,7 +357,16 @@ class TestJsonpath < MiniTest::Unit::TestCase
|
|
343
357
|
}
|
344
358
|
}
|
345
359
|
assert_equal(['@Place'], JsonPath.new("$..mentions.type[?(@ == '@Place')]").on(jsonld))
|
346
|
-
end
|
360
|
+
end
|
361
|
+
|
362
|
+
def test_parens_in_value
|
363
|
+
data = {
|
364
|
+
'data' => {
|
365
|
+
'number' => '(492) 080-3961'
|
366
|
+
}
|
367
|
+
}
|
368
|
+
assert_equal [{'number'=>'(492) 080-3961'}], JsonPath.new("$.data[?(@.number == '(492) 080-3961')]").on(data)
|
369
|
+
end
|
347
370
|
|
348
371
|
def example_object
|
349
372
|
{ 'store' => {
|
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.10
|
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-10-
|
12
|
+
date: 2017-10-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: multi_json
|
@@ -143,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
143
143
|
version: '0'
|
144
144
|
requirements: []
|
145
145
|
rubyforge_project: jsonpath
|
146
|
-
rubygems_version: 2.
|
146
|
+
rubygems_version: 2.4.8
|
147
147
|
signing_key:
|
148
148
|
specification_version: 4
|
149
149
|
summary: Ruby implementation of http://goessner.net/articles/JsonPath/
|