lib/jsonpath/parser.rb in jsonpath-0.8.8 vs lib/jsonpath/parser.rb in jsonpath-0.8.10
- old
+ new
@@ -20,20 +20,20 @@
end
ret
end
def parse_exp(exp)
- exp = exp.sub(/@/, '').gsub(/[\(\)]/, '').gsub(/"/, '\'').strip
+ exp = exp.sub(/@/, '').gsub(/^\(/, '').gsub(/\)$/, '').gsub(/"/, '\'').strip
scanner = StringScanner.new(exp)
elements = []
until scanner.eos?
if scanner.scan(/\./)
sym = scanner.scan(/\w+/)
op = scanner.scan(/./)
num = scanner.scan(/\d+/)
return @_current_node.send(sym.to_sym).send(op.to_sym, num.to_i)
end
- if t = scanner.scan(/\['[a-zA-Z@&\*\/\$%\^\?]+'\]+/)
+ if t = scanner.scan(/\['[a-zA-Z@&\*\/\$%\^\?_]+'\]+/)
elements << t.gsub(/\[|\]|'|\s+/, '')
elsif t = scanner.scan(/(\s+)?[<>=][<>=]?(\s+)?/)
operator = t
elsif t = scanner.scan(/(\s+)?'?.*'?(\s+)?/)
operand = t.delete("'").strip