Summer Deals - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
What is JSON
4. What data types are used in JSON?
Summary

Instruction

Have another look at our example:

{
  "first_name": "Guido",
  "last_name": "van Rossum",
  "titles": ["BDFL", "Developer"], 
  "age": 63,
  "married": true
}

A JSON file can store a variety of data types:

  • Objects are name-value pairs that are placed inside curly braces ({}) and correspond to Python dictionaries.
  • Arrays are placed inside brackets ([]) and correspond to Python lists.
  • Strings are placed inside a pair of double quotes (e.g., "Guido").
  • Numbers must be either an integer or a floating-point value.
  • Logical values are either true or false and correspond to the Python values of True and False, respectively.
  • null in JSON represents "no value" and corresponds to None in Python.

Each JSON data type corresponds to a Python data type. We'll learn how to transfer information between the two languages later in this course.

Exercise

True or False: Answer by assigning True or False to the variable below the given statement.