TechieClues . TechieClues .
Updated date Feb 23, 2021
How to Read a JSON File in Python

This code snippet shows how to read a JSON file (JSON stands for JavaScript Object Notation, ) in python. We can use json.load() method to read a JSON file in python. In the below example, we use emp_details.json file which contains JSON objects.

JSON File (emp_details.json):

	"name": "Sabari", 
	"Country": "India",
	"languages": ["English", "Tamil", "Hindi"]

First, we need to import the JSON module and use open() method to open the file and json.load() is used to read and parse the JSON file and provides the dictionary named data as shown below,

import json

with open(r'D:\emp_details.json') as f:
  data = json.load(f)



{'name': 'Sabari', 'Country': 'India', 'languages': ['English', 'Tamil', 'Hindi']}


TechieClues .
TechieClues .
Software Professional, India

IT professional with 15+ years of experience in Microsoft Technologies with a strong base in Microsoft .NET (C#.Net, ASP.Net MVC, ASP.NET WEB API, Webservices,...Read More

Comments (0)

There are no comments. Be the first to comment!!!