lib/jsonpath/parser.rb in jsonpath-0.8.7 vs lib/jsonpath/parser.rb in jsonpath-0.8.8
- old
+ new
@@ -20,20 +20,20 @@
end
ret
end
def parse_exp(exp)
- exp = exp.gsub(/@/, '').gsub(/[\(\)]/, '').gsub(/"/, '\'').strip
+ exp = exp.sub(/@/, '').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(/\['\w+'\]+/)
+ 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