Menu
Coddy logo textTech

JSON vs Python Data Types

Lesson 2 of 9 in Coddy's Python JSON course.

JSON and Python have similar data types, but there are some key differences. Let's compare the JSON data types with their Python equivalents:

JSON Type Python Equivalent Example
Object Dictionary

# JSON
{"name": "John", "age": 30}

# Python
{"name": "John", "age": 30}
      
Array List

# JSON
[1, 2, 3, 4]

# Python
[1, 2, 3, 4]
      
String String

# JSON
"Hello, World!"

# Python
"Hello, World!"
      
Number (integer) Integer

# JSON
42

# Python
42
      
Number (float) Float

# JSON
3.14

# Python
3.14
      
Boolean Boolean

# JSON
true, false

# Python
True, False
      
Null None

# JSON
null

# Python
None
      

Key differences to note:

  • JSON uses lowercase true, false, and null, while Python uses True, False, and None.
  • JSON doesn't have a distinction between integers and floats; both are considered numbers.
  • Python has more complex data types (like tuples, sets) that don't have direct JSON equivalents.

Understanding these mappings is crucial when working with JSON data in Python, as it affects how data is encoded and decoded between the two formats.

quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

Try it yourself

This lesson doesn't include a code challenge.

All lessons in Python JSON