(no title)
schmooser | 5 years ago
Babashka[1] with Cheshire[2] aliased as json solves this to me, the code is longer but no need for googling anymore:
USERX='{"name":"duchess","city":"Toronto","orders":[{"id":"x","qty":10},{"id":"y","qty":15}]}'
echo $USERX | jq '.orders[]|select(.qty>10)'
{
"id": "y",
"qty": 15
}
echo $USERX | bb -i -o '(-> *input* first (json/decode true) (->> :orders (filter #(> (:qty %) 10))))'
{:id y, :qty 15}
[1]: https://github.com/borkdude/babashka
[2]: https://github.com/dakrone/cheshire
No comments yet.