Video 11: JSON Files (page 2 of 4) |
JSON files have a few core properties:
1. Data are stored in key-value pairs. The key is often referred to as a name but it is functionally equivalent to a key in a Python dictionary.
2. Rows of data are separated by commas in a JSON file.
3. Curly braces {} hold objects that we can read into Python. The object is essentially a Python dictionary.
4. Hard brackets [] hold arrays, which are Python lists when read into Python.
To read in a JSON file into Python, it must be well-formed, which means that all left curly braces { must be matched with corresponding right curly braces } and all left hard brackets [ must be matched with corresponding right hard brackets ]. Attempting to import a non-well-formed JSON file using the json module in Python will result in a Traceback error message.