Home > Unix > Find keys from a JSON file

Find keys from a JSON file

Find all keys of a json file.

Assume, the Input JSON file is  tweet1.json which is actually a  Twitter Tweet.

Finding all the JSON keys of the JSON file:

grep  ‘[a-z]*[:]’ tweet1.json | awk ‘{print $1}’

Finding all the unique keys of the JSON file:

grep  ‘[a-z]*[:]’ tweet1.json | awk ‘{print $1}’| sort  | uniq -c

Find all the duplicate keys of the JSON file:

   grep  ‘[a-z]*[:]’ tweet1.json | awk ‘{print $1}’| sort  | uniq -d -c

Advertisements
Categories: Unix
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: