Hello ,
I want to read a json file and get 2 objects form the file (username and IP )
the config.json is :
this is what I did to read the all file :
I have also try to use:
but I get error
so what am I missing?
Thanks,
I want to read a json file and get 2 objects form the file (username and IP )
the config.json is :
Output:{
"IP":"172.16.3.1",
"username" : "admin",
"password" : "Root",
"Remote":"172.16.3.254",
"internalNumber":31",
"comId":2,
}
how do I do this? this is what I did to read the all file :
1 2 3 4 5 |
import json with open ( '/home/pi/Documents/config.json' ) as json_file: data = json.load(json_file) print (data) |
1 2 |
j = json.loads( '/home/pi/Documents/config.json' ) print (j[ 'IP' ]) |
so what am I missing?
Thanks,