''' DS2000 Spring 2020 Source code from class - processing a JSON file ''' import json def process_json(filename): ''' Function process_json Parameter: Name of the json file, a string Returns: Dictionary containing everything from the file ''' with open(filename) as json_file: dct = json.load(json_file) return dct def main(): # This particular file contains a dictionary, where # the key is 'genres' and the value is a list of dictionaries all_data = process_json('genres.json') # Get the list of dictionaries alone # and sanity-check print it all out dcts = all_data['genres'] print('List of dictionaries', dcts) # Print out just the genre names for dct in dcts: print(dct['name']) main()