Using `json.dumps()` in Python
Author: Newtum
This example explains how to use the `json.dumps()` (dump string) method to serialize a Python object (like a dictionary or list) into a JSON formatted string.
Basic Serialization
`json.dumps()` converts a Python dictionary into a compact JSON string, which is ideal for sending data over a network.
Pretty-Printing with Indentation
You can make the output more readable by using the `indent` parameter. This is very useful for debugging and logging.
Sorting Keys
For consistent output, especially for caching or comparisons, you can sort the keys in the JSON output using `sort_keys=True`.