I am a beginner in python. Could you kindly advise me on how I should proceed to extract the value id for keys from the .json file in python. I am currently comparing the key using 'if' condition and then i am stuck as to how I should proceed to get the relevant value.I have written the json contents into a file my code is : ( this is for a YOUTUBE API)
f = open('python_JSON_YOUTUBE.json', 'w+')
s=str(data)
f.write(s)
c = f.read()
if c == "\"items\"":
if c == "\"kind\"":
cursor1.execute ("""INSERT INTO youtube_channel (kind) VALUES(%s)""", ( , ))
Import the
JSON
module:Now, having a JSON formatted string:
Load the string (variable
dictionary
becomes a dictionary):Just operate with
dictionary
as you would with any Python dictionary, i.e.: