Dict-With-Indent

Sat 17 May 2025
import json

# Example dictionary
result_dict = {
    "name": "John Doe",
    "age": 30,
    "location": {
        "city": "New York",
        "country": "USA"
    }
}

# Convert dictionary to JSON string with indentation
formatted_json = json.dumps(result_dict, indent=4)

# Print the formatted JSON
print(formatted_json)
{
    "name": "John Doe",
    "age": 30,
    "location": {
        "city": "New York",
        "country": "USA"
    }
}
from IPython.display import JSON
JSON(result_dict)
<IPython.core.display.JSON object>


Score: 0

Category: langchain