String#to_proc`
String#to_proc` to Help Traversing JSON I've resuscitated a project I was working on years ago. I was tired of having nested `flat_map` making my code basically unreadable just to fetch a simple value. The idea is to make simple & readable the traversing of deeply nested structures like JSON responses, while staying in Ruby & keeping its flexibility. Here it goes: graphql_response.then(&'[data][repository][issues][edges]*([node][title])') # => ["Support negative indexes", "Document aggregates"] github_prs_response.then(&'*[draft].any?') # => true It's different from jq or JSONPath in that: - it's a Ruby block so you can use it with `map`, `find`, etc. - you can call Ruby method from it - it doesn't automatically flatten arrays, you decide - it raises on `nil` by default (unless you use `&`, i.e. `[customer][address]&[city]`) Obviously, it has drawbacks: - it's yet another syntax to learn - it monkey-patches `String` which might be a blocker for some I'm really looking for feedback here, what do you think? Is it worth releasing a gem with this value proposition?