Skip to main content
Solved

Extracting infos from a .json file

  • February 20, 2025
  • 2 replies
  • 19 views

Forum|alt.badge.img+4

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.

Best answer by karthikeyan_mac

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. 

2 replies

karthikeyan_mac
Forum|alt.badge.img+18
  • Honored Contributor
  • Answer
  • February 20, 2025

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. 


Forum|alt.badge.img+4
  • Author
  • Contributor
  • February 24, 2025

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!