0PricingLogin
Flask Academy · Lesson

Return Lists and Nested Data

Serialize arrays and nested objects safely.

Beyond a Single Object

Real APIs rarely return one item. They return collections and richer shapes, so you need jsonify to handle lists and nested data with ease. 📦

Lists Become JSON Arrays

A Python list maps directly onto a JSON array. Build a list of dictionaries and jsonify serializes the whole collection at once.

users = [{"name": "Ada"}, {"name": "Linus"}]

All lessons in this course

  1. jsonify a Dictionary
  2. Return Lists and Nested Data
  3. Set Status Codes on JSON Replies
  4. Content-Type and the Accept Header
← Back to Flask Academy