Python json.dumps() Method
The json.dumps() method converts a Python object into a JSON
string.
Syntax
json.dumps(obj)
Parameters
| Parameter | Description |
|---|---|
obj |
Required. The object to convert to JSON. |
indent |
Optional. Use the indentation parameter to define the numbers of indents. |
sort_keys |
Optional. Use the sort_keys parameter to specify if the result should be sorted or not. |
Return Value
A JSON string.
Example
Using the json.dumps() method:
Output
Click Run to execute your code
Enjoying these tutorials?