From the course: Python Standard Library Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Using JSON

Using JSON - Python Tutorial

From the course: Python Standard Library Essential Training

Start my 1-month free trial

Using JSON

- One of the most common data formats on the internet today is JSON, which is an acronym that stands for "JavaScript Object Notation". The Python JSON module makes working with JSON data really simple and you can learn more about that module at this link. For this example, we're also going to use the httpbin.org testing site... for the source of our sample JSON data. And so, if I go to this site /json, you can see that these... There are some sample JSON data being returned here. So let's go to our code. So here, in json_start, we're going to use the urllib module to request some data from the internet, and I've also imported the JSON module for working with the JSON. So to get started, let's use the urllib module to request data from the internet. And so, I'll use the request and I'll call urlopen, and that's going to be on the JSON website. So that's httpbin.org/json, and then, I'm going to read the data... So I'll call req.read, and then, I need to decode that into a text string…

Contents