Consuming HTTP Services in Python Transcripts
Chapter: Reading JSON data with requests
Lecture: Concept: JSON from Python

Login or purchase this course to watch this video and the rest of the course contents.
0:01 So you've seen Json parsing and serialization in action in Python, let's review the key concepts that were in play;
0:09 so this is more or less the same code that we just wrote and remember we started with importing of the Json module,
0:14 this is a built in thing in the standard libraries, this is a built in thing in the Python standard library
0:20 so we didn't have to install an external package to get this support, we just import Json and we're off to the races, so we started with Json text
0:26 which is just an in memory version of some Json string representation,
0:32 and we want to turn that into something that we could actually work with in Python, so what we did is we called the load s, load from sting,
0:38 and we passed the Json text in to be parsed, we got back data, which we saw was a dictionary, so we have this dictionary,
0:45 we work with it however you work with dictionaries in Python using get, assigning to a key to change the values,
0:52 things like that and then to get the data back out, to send it off to somewhere to save it to a file of course we just did a dump s, dump to string
0:59 and what we get back is more text, now, it's worth noting that the thing that came out here is sort of somewhat minified Json,
1:07 there is no like line breaks or indentation or anything pretty about it, you can set an indentation setting on the dump s method
1:14 and it will be a little bit nicer text if you care about readability.


Talk Python's Mastodon Michael Kennedy's Mastodon