A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://realpython.com/lessons/serializing-json-data/ below:

Serializing JSON Data (Video) – Real Python

In this video, you’ll learn how to serialize Python objects into JSON.

The json module exposes two methods for serializing Python objects into JSON format.

dump() will write Python data to a file-like object. We use this when we want to serialize our Python data to an external JSON file.

dumps() will write Python data to a string in JSON format. This is useful if we want to use the JSON elsewhere in our program, or if we just want to print it to the console to check that it’s correct.

Python and JSON do not share all the same types. Serialization will convert your Python objects into JSON format according to this table

Python JSON dict object list, tuple array str string int, long, float number True true False false None null

Both the dump() and dumps() methods allow us to specify an optional indent argument. This will change how many spaces is used for indentation, which can make our JSON easier to read.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4