Solution Review: Convert an Object to JSON File
This review provides a detailed explanation of the solution to the "Convert an Object to JSON File" challenge.
We'll cover the following...
Solution
Let’s understand the solution of the challenge in Python and Powershell.
Python
Note: Run the
cat jfile.json
command after hitting the “Run” button to see the output.
import json age = { 'david': 34, 'prateek': 35, 'singh': 18 } # Write your code here ## writing the objects to a file serialized in XML format with open("/usercode/jfile.json", "w") as filehandler: json.dump(age, filehandler)
Solution in Python
Explanation
- To use