Navigation X
ALERT
Click here to register with a few steps and explore all our cool stuff we have to offer!

cracked.io | Best Forum Around | Free Premium Accounts




 3676

[sunjester tuts] Parsing JSON in Bash

by sunjester - 13 March, 2019 - 12:14 AM
This post is by a banned member (sunjester) - Unhide
sunjester  
Registered
18
Posts
12
Threads
5 Years of service
#1
There comes a time when you need to format some JSON in unix, in that case, use jq.
 
Install jq
Code:
sudo apt-get -y install jq
Using jq
 
So let's parse some JSON, let's use the nulled feed, first download the feed to a file
Code:
curl -s https://www.nulled.to/misc.php?action=getFeed >feed
Now let's parse some of it, let's try the home stuff
Code:
jq '.home' feed
[img=https://i.imgur.com/e6Rwmz4.png]
 
so if we wanted to get the titles from the .home section of the feed
Code:
jq '.home[].title' feed
[img=https://i.imgur.com/1EsHFUP.png]
Code:
#!/bin/sh
curl -s https://www.nulled.to/misc.php?action=getFeed >feed
jq '.home[].title' feed
rm feed
This post is by a banned member (socalgurl) - Unhide
socalgurl  
Registered
10
Posts
0
Threads
5 Years of service
#2
thanks for this
This post is by a banned member (hasi912) - Unhide

Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
or
Sign in
Already have an account? Sign in here.


Forum Jump:


Users browsing this thread: 1 Guest(s)