title: How to return JSON objects (List of Dictionaries) in Flask API
body: <p>Newbie here and stuck on returning some objects from JSON to my Flask API.</p>
  
  <p>I have a list of dictionaries called data, you'll see in my code below. I need to check if the status_id is in the data. If it is, I have to display that user's name. How would I access a dictionary from a list? Or is my json not valid? I did use a linter to check and it passed the JSON test. I'm getting error: string indices must be integers. Which leads me to believe that since it's a list I'll need integers for the indexes.</p>
  
  <p>Any help in the right direction would be great.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>@app.route("/status/&lt;status_id&gt;", methods=['GET'])
  def get_status(status_id):
      data = [{
                  "id": 5,
                  "name": "Meghan"
              },
              {
                  "id": 6,
                  "name": "Julia"
              }
          ]
  
      data_dump = json.dumps(data, indent=4)
  
      if status_id in data_dump:
          #find that status id and name and return it
          return data_dump[status_id]['name']
      else:
          return "Not Found in Dictionary"
  </code></pre>