Skip to content

Instantly share code, notes, and snippets.

@hillar
Created December 17, 2014 07:03
Show Gist options
  • Save hillar/1ca824d37cbbe94d7ba3 to your computer and use it in GitHub Desktop.
Save hillar/1ca824d37cbbe94d7ba3 to your computer and use it in GitHub Desktop.
simple python snippet to print first level of json key names
import json
fn='/opt/suricata/var/log/suricata/eve.json'
f=open(fn)
lines=f.readlines()
f.close()
u=dict()
for line in lines:
try:
j=json.loads(line)
for key in j:
if not key in u:
u[key]=j[key]
except :
pass
for k in u:
print k, '|',u[k]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment