From 44e1d8067a2b487f1a45d454ef3be926c24a78b1 Mon Sep 17 00:00:00 2001 From: Gergely Brautigam Date: Tue, 9 May 2017 16:19:11 +0200 Subject: [PATCH] Fix for #52 --- lib/jsonpath/enumerable.rb | 3 +-- lib/jsonpath/version.rb | 2 +- test/test_jsonpath.rb | 4 ++++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/jsonpath/enumerable.rb b/lib/jsonpath/enumerable.rb index 1a51529..7a1f490 100644 --- a/lib/jsonpath/enumerable.rb +++ b/lib/jsonpath/enumerable.rb @@ -115,7 +115,7 @@ def process_function_or_literal(exp, default = nil) return Integer(exp) if exp[0] != '(' return nil unless allow_eval? && @_current_node - identifiers = /@?(\.(\w+))+/.match(exp) + identifiers = /@?((? 9)]").on(@object) end + def test_eval_with_floating_point + assert_equal [@object['store']['book'][1]], JsonPath.new("$..book[?(@['price'] < 23.0 && @['price'] > 9.0)]").on(@object) + end + def test_no_eval assert_equal [], JsonPath.new('$..book[(@.length-2)]', allow_eval: false).on(@object) end