import json
# Your Python dictionary
user_profile = {
"name": "Alice",
"age": 30,
"is_member": True,
"skills": ["Python", "Data Science"]
}
# Convert to JSON string
json_string = json.dumps(user_profile)
print(json_string)with open("data.json", "w", encoding="utf-8") as file:
json.dump(user_profile, file)pretty_json = json.dumps(user_profile, indent=4, sort_keys=True)
print(pretty_json)