lib/jsonpath.rb in jsonpath-1.0.7 vs lib/jsonpath.rb in jsonpath-1.1.0
- old
+ new
@@ -1,22 +1,30 @@
# frozen_string_literal: true
require 'strscan'
require 'multi_json'
require 'jsonpath/proxy'
+require 'jsonpath/dig'
require 'jsonpath/enumerable'
require 'jsonpath/version'
require 'jsonpath/parser'
# JsonPath: initializes the class with a given JsonPath and parses that path
# into a token array.
class JsonPath
PATH_ALL = '$..*'
+ DEFAULT_OPTIONS = {
+ :default_path_leaf_to_null => false,
+ :symbolize_keys => false,
+ :use_symbols => false,
+ :allow_send => true
+ }
+
attr_accessor :path
def initialize(path, opts = {})
- @opts = opts
+ @opts = DEFAULT_OPTIONS.merge(opts)
scanner = StringScanner.new(path.strip)
@path = []
until scanner.eos?
if (token = scanner.scan(/\$\B|@\B|\*|\.\./))
@path << token