title: Reading JSON Array Values in Python / Flask
body: <p>I have the following JSON data the I need to read in Flask:</p>
  
  <pre><code>{
  "NewList":[
      {
          "key" : "myvalue1",
          "value" : "value1"
      },
      {
          "key" : "myvalue2",
          "value" : "value2"
      },
      {
          "key" : "myvalu3",
          "value" : "value4"
      }
  ]
  }
  </code></pre>
  
  <p>And I'm having trouble doing so. The code I currently have is as follows:</p>
  
  <pre><code>@app.route('/dataread', methods=['GET', 'POST'])
  def dataread():
      if(request.json):
              myvalue1 = request.json['NewList']['myvalue1']
              return str(myvalue1)
          else:
              return 'nothing'
  </code></pre>
  
  <p>But it isn't working. I'm getting the following error:</p>
  
  <p>KeyError: 'NewList'</p>
  
  <p>I know my syntax must be wrong but I can't figure how to fix it. I'm sorry for such a newb question. Please can you help.</p>
  
  <p>Thanks.</p>