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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8b673224572aaaea3d5ba2948972cbb91f52f4840dd9c94a95bf9aa41ca01c25
4
- data.tar.gz: fc479848668ed538913eba2592013258c3904da6fa3e9c93a15317751a25f69d
3
+ metadata.gz: ffcdd9076a2bd58ead93c850c8a1ed842a202e6db62314fb2b6c8fd5f8650fb5
4
+ data.tar.gz: 3d6624bd18086aa892f93bff141dd7bf33e516e02c3fd7e8828db13eb3a84436
5
5
  SHA512:
6
- metadata.gz: 7fe9d998deccdd22c3b310eedd4aa0e6fdc70ccc3efeaa056a68b13cdd9ce394e1287e0763e0142dee8d19d0d86f161505029608c8023231f205934a396449b5
7
- data.tar.gz: 30b855edde51f13a1b7f805fd566aa23a3f6b9aeb33b819a1e80a3d30169e375c6ab3e3e9500dd974b1d15892f6311c624d8813fc6cafd40e00c51cf6cc3c227
6
+ metadata.gz: 492ed8f729cfdb038c2b0303f49bf2bf1bfb85bd4a7d6ae2e37c2b559bf288b73110db65b2c1642f4e1954cde213d10488ab996ad9261c108f253f03aeb41d12
7
+ data.tar.gz: 2642b36da6a171649a9b0dc2e973994a7d3268e71a62ea290e75f91bd7f7af621b0b0dd6d9fb6a1f7148943f2c5ce6965f8de0db69db4041bc973576b7694425
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class JsonPath
4
- VERSION = '1.1.4'
4
+ VERSION = '1.1.5'
5
5
  end
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[:symbolize_keys]
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
@@ -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
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-09-27 00:00:00.000000000 Z
12
+ date: 2023-10-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_json