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

Cracked.to | Best Cracking Forum Around | Free Premium Accounts




 601

[sunjester tuts] Parsing JSON in Bash

by sunjester - 1 year ago
This post is by a banned member (sunjester) - Unhide
sunjester  
Registered
0
Rep
42
Likes
Posts: 19
Threads: 12
Joined: Mar 2019
Vouches: 0
Credits: 5.510
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
0
Rep
10
Likes
Posts: 10
Threads: 0
Joined: Mar 2019
Vouches: 0
Credits: 0
#2
thanks for this

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)