can't read json file with python. getting type error: json object is 'TextIOWrapper'

json.load() is for loading a file. json.loads() works with strings.


3 ways to load a json file:

import json
import ast
with open(file_path) as file:
    data1 = json.load(file)
    data2 = json.loads(file.read())  
    data3 = ast.literal_eval(file.read())

You should use json.load whenever possible, but sometimes the JSON file is not strictly in the correct format (e.g. single quotes instead of double quotes). A solution is to use ast.literal_eval().