read_json.py 323 Bytes
Newer Older
Marco Govoni's avatar
Marco Govoni committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import json
import sys
import os.path

def main():

    fname = str(sys.argv[1])
    key = str(sys.argv[2])

    if os.path.isfile(fname):
       with open(fname,"r") as file:
          data = json.load(file)
    else : 
       print("Cannot find FILE: ",fname)
    print(data[key])

if __name__ == "__main__":
    main()