Created
December 17, 2014 07:03
-
-
Save hillar/1ca824d37cbbe94d7ba3 to your computer and use it in GitHub Desktop.
simple python snippet to print first level of json key names
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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