Skip to content
Muthupandian @muthugit
2022-01-03 2023-02-12

Read JSON file in Python

# Import JSON library
import json

class JSONReader:
    def __init__(self, file_path: str):
        self.file_path = file_path

    def read(self):
        with open(self.book_path, 'r') as myfile:
            data = myfile.read()
        return json.loads(data)

if __name__ == "__main__":
    reader = JSONReader("/tmp/a.json")
    print(reader.read())