jsonpath 1.1.4 → 1.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jsonpath/version.rb +1 -1
- data/lib/jsonpath.rb +5 -1
- data/test/test_jsonpath.rb +6 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ffcdd9076a2bd58ead93c850c8a1ed842a202e6db62314fb2b6c8fd5f8650fb5
|
4
|
+
data.tar.gz: 3d6624bd18086aa892f93bff141dd7bf33e516e02c3fd7e8828db13eb3a84436
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 492ed8f729cfdb038c2b0303f49bf2bf1bfb85bd4a7d6ae2e37c2b559bf288b73110db65b2c1642f4e1954cde213d10488ab996ad9261c108f253f03aeb41d12
|
7
|
+
data.tar.gz: 2642b36da6a171649a9b0dc2e973994a7d3268e71a62ea290e75f91bd7f7af621b0b0dd6d9fb6a1f7148943f2c5ce6965f8de0db69db4041bc973576b7694425
|
data/lib/jsonpath/version.rb
CHANGED
data/lib/jsonpath.rb
CHANGED
@@ -80,7 +80,7 @@ class JsonPath
|
|
80
80
|
|
81
81
|
def on(obj_or_str, opts = {})
|
82
82
|
a = enum_on(obj_or_str).to_a
|
83
|
-
if opts
|
83
|
+
if symbolize_keys?(opts)
|
84
84
|
a.map! do |e|
|
85
85
|
e.each_with_object({}) { |(k, v), memo| memo[k.to_sym] = v; }
|
86
86
|
end
|
@@ -153,4 +153,8 @@ class JsonPath
|
|
153
153
|
return unless @opts[:max_nesting].is_a?(Integer) && @opts[:max_nesting] > MAX_NESTING_ALLOWED
|
154
154
|
@opts[:max_nesting] = false
|
155
155
|
end
|
156
|
+
|
157
|
+
def symbolize_keys?(opts)
|
158
|
+
opts.fetch(:symbolize_keys, @opts&.dig(:symbolize_keys))
|
159
|
+
end
|
156
160
|
end
|
data/test/test_jsonpath.rb
CHANGED
@@ -1312,4 +1312,10 @@ class TestJsonpath < MiniTest::Unit::TestCase
|
|
1312
1312
|
assert_equal ["success"], JsonPath.on(json, "$.test.$")
|
1313
1313
|
assert_equal ["123"], JsonPath.on(json, "$.test.a")
|
1314
1314
|
end
|
1315
|
+
|
1316
|
+
def test_symbolize_key
|
1317
|
+
data = { "store" => { "book" => [{"category" => "reference"}]}}
|
1318
|
+
assert_equal [{"category": "reference"}], JsonPath.new('$..book[0]', symbolize_keys: true).on(data)
|
1319
|
+
assert_equal [{"category": "reference"}], JsonPath.new('$..book[0]').on(data, symbolize_keys: true)
|
1320
|
+
end
|
1315
1321
|
end
|
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: 1.1.
|
4
|
+
version: 1.1.5
|
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: 2023-
|
12
|
+
date: 2023-10-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: multi_json
|