From the course: Data Ingestion with Python

Unlock the full course today

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

Working with JSON

Working with JSON - Python Tutorial

From the course: Data Ingestion with Python

Start my 1-month free trial

Working with JSON

- [Instructor] One of the of the most common serialization formats in APIs is JSON. There are many other serialization formats available and if you have a say in which format to use do your homework first. Since JSON is a cross language format, it means that not all python types are supported. For example, you can't serialize python set into JSON. If you'd like to do that, you need to have the JSON decoder and encoder a bit. Let's see. In line five, we have data in JSON format. Note the b in front which means this is a bytes object. And we have a transaction from Wile E. Coyote to ACME corporation $103.7 and it was in August 2019. The first three types convert from python to JSON and back but the time does not, it's currently in JSON as a String and we'd like to make it a datetime object. What we're going to do is use two auxiliary functions. The fix time which takes a pair and if it's a pair with the key's we'll pass the string into a datetime object. And object pairs hook which will…

Contents