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?
Comments URL: https://news.ycombinator.com/item?id=50491929
Points: 2
# Comments: 0
![Safety Architecture — Ch.09: Safety Network [EN]](https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fybanqvv63pf5yqcxykgt.png)
![Safety Architecture — Ch.10: UAV Safety Architecture [EN]](https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fd46f0ihvpl3c1pi8z1h1.png)
![Safety Architecture — Ch.11: Functional Safety Case Studies [EN]](https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F1465u5hoi4r9ybf4zkvf.png)