Closed zenlor closed 3 years ago
I would suggest doing something along the lines of:
(defn vals-with-prefix [s]
(path ALL (selected? FIRST NAME #(string/starts-with? % s)) LAST))
(select [(vals-with-prefix "foo") <rest of path>] data)
Thanks!
I knew I was missing something important. using path
will make my code far cleaner and easier to read, understand and even compose.
Hello I have a question, I want to use specter to select large JSON bodies coming from ElasticSearch's statistics. Some of the statistics I'm trying to reach have dynamic path names, at this time I'm only interested in
select
them.I'll have to compose selectors from my program's dynamic configuration. I'm trying to find the best way to tackle this using specter to cleanup my current clojure code (which I found difficult to debug and share with a team).
My data would have nested paths, but this should suffice as streamlined example:
In this example I'm only selecting the matching maps, in the real program I'll select a number of values to run statistics on them.
My first attempt was using
if-path
, it still needs to selectALL
and thenMAP-VALS
in the end. In my second attempt I'm doing the same asif-path
with a set of functions and a dynamic navigator.It feels like I'm missing something important about specter.
Thank you for any insights.