Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/jsonpath/enumerable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def yield_value(blk, context, key)
if key
context[key] = blk.call(context[key])
else
context.replace(blk.call(context[key]))
context.replace(blk.call(context))
end
end
end
Expand Down
4 changes: 4 additions & 0 deletions test/test_jsonpath.rb
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,10 @@ def test_join
assert_equal JsonPath.new('$.store.book..author').on(@object), JsonPath.new('$.store').join('book..author').on(@object)
end

def test_gsub_with_nokey
assert_equal @object2, JsonPath.for(@object).gsub('$..*[?(@.category=="fiction")]') { |v| v }.to_hash
end

def test_gsub
@object2['store']['bicycle']['price'] += 10
@object2['store']['book'][0]['price'] += 10
Expand Down