-1
{
    "WordsEntered": [
        {
            "Word": "test"
        },
        {
            "Word": "Test1"
        },
        {
            "Word": "Test2"
        }
    ]
}

Hi i want to get the data from this JSON file. I want to do this with a python script. I just want the python script to print the three words like: test, Test1, Test2. Can someone pls help me? Iam very new to python/json.

Ties
  • 71
  • 5

1 Answers1

1
import json
# open file and read data
with open('your_json_data.json') as f:
    d = json.loads(f.read())# convert JSON text to python dictionary
    l = d['WordsEntered']
# print data
for d in l:
    print(d['Word'])
Hadrian
  • 917
  • 5
  • 10
  • why not just `d = json.load(f)`? And using one-char names, especially like `l` is not good idea – buran Oct 11 '20 at 14:21