
This will give you an object which will contain all the specific details related to the address field like Apartment no., street name, zip code, and so on. It will print the name of the user inside the console.Īnd to access the address we have to pass the address key inside the user variable i.e user, and then store it inside a variable called address and then print it. To access the name, we just have to pass the name key inside the user variable like user and then print it. Now this users is an object which contains all the details related to that user. To access the first user from the list of users, we have to use the 0 index from the JSON data, which is stored inside a variable called data, and then store the entire details of that first inside user. In JSON, we use two types of brackets to format the data one is the square brackets representing an array or a list, and the other is the curly braces Here, don’t get confused with the word JavaScript JSON is independent of any programming language. It is used to send and receive data between a server and a client and vice versa. The JSON refers to JavaScript Object Notation. Reading text file in python with source code 2020 Free Download But if you visit the URL, you will see the data for all the users. Note that we have only shown you the JSON data related to a single user in the above code block. "catchPhrase": "Multi-layered client-server neural-net", If you open the above URL in the browser, you will see all the data related to users in JSON format. In the above URL, /users refers to an endpoint. Throughout this tutorial, we will be using these two words interchangeably. In terms of Restful APIs, URLs are called endpoints. This URL allows us to fetch all the data related to the users like name, email, address, etc.

The JSON data which we will be fetching is from the below URL.

Throughout this tutorial, we will use json and requests modules, which are available in Python. There are various libraries in Python to process JSON. We prefer JSON over XML because it has become quite popular in the software industry. In general, whenever we want to fetch any data from the web server, we use either JSON or XML formats. Whenever we want to get any data from a web server using a URL, then that data should have some particular format.
