Practical JSON at the command line using Jello (Part 1) #27
kellyjonbrazil
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
A while back I wrote an article on my blog on ways to use
jc
andjq
instead ofsed
,awk
,grep
, etc. to extract the data you want from command output. I thought I would post those same examples of filtering the JSON converted data from therpm
command usingjello
this time.List the package objects that use the MIT license
Here is the method in
jq
:And here is how you can do the same thing in
jello
:As you can see, we can use a simple list comprehension to get the same result.
Grab the name of the latest MIT licensed package
To grab the newest MIT licensed package installed we can use the following
jq
filter:And here's how you do it in
jello
:Oh look - it's
jc
! We could also do it this way using theoperator
module:Finally, we can do it with a good old-fashioned loop:
As you can see, there is more than one way to skin a cat in
jello
using the Python interpreter. That's it for this post. I'll add more examples in another. Do you have other ways to solve this problem injello
?Beta Was this translation helpful? Give feedback.
All reactions