Extracting infos from a .json file

DonCascone
New Contributor III

Recently I've been trying to extract infos of which extensions our users have on their browsers.
I have a script running for our major browsers and it's working great but now I'd like to get more infos that are sealed inside a .json file.
Is there a way to extract specific lines from a .json file such as the "manifest.json" you can find in every Chrome extension's folder?
Specifically I need only the rows talking about which permission does the extension have as seen below.Screenshot 2025-02-20 at 10.04.49.png

1 ACCEPTED SOLUTION

karthikeyan_mac
Valued Contributor

Hi @DonCascone 

You can use jq to extract and print the permissions or grep & sed. Please test it. I am not expert :)

 

jq -c '.permissions' manifest.json

or

grep '"permissions"' manifest.json | head -1 | sed -E 's/.*"permissions":\s*\[([^]]*)\].*/[\1]/'

 

 Thanks. 

View solution in original post

2 REPLIES 2

karthikeyan_mac
Valued Contributor

Hi @DonCascone 

You can use jq to extract and print the permissions or grep & sed. Please test it. I am not expert :)

 

jq -c '.permissions' manifest.json

or

grep '"permissions"' manifest.json | head -1 | sed -E 's/.*"permissions":\s*\[([^]]*)\].*/[\1]/'

 

 Thanks. 

DonCascone
New Contributor III

jq was, in fact, the solution. 
Had to jumps through some loops to deploy it to all my macs but now it works.
Thank you!