title: Comparing value in a JSON using Python
body: <p>I receive a fairly uncomfortable JSON to work with, which looks as follows:</p>
  <pre><code>[
  {
      &quot;attributes&quot;: [
          {
              &quot;type&quot;: &quot;COMMAND&quot;,
              &quot;name&quot;: &quot;COMMAND&quot;,
              &quot;value&quot;: [
                  &quot;buttonState&quot;
              ]
          },
          {
              &quot;type&quot;: &quot;std_msgs.msg.Bool&quot;,
              &quot;name&quot;: &quot;buttonState&quot;,
              &quot;value&quot;: {
                  &quot;data&quot;: false
              }
          }
      ],
      &quot;type&quot;: &quot;sensor&quot;,
      &quot;id&quot;: &quot;s_2&quot;
  }]
  </code></pre>
  <p>And I would like to compare a piece of data (more precisely - value of Button state) but I seem to fail. Tried following:</p>
  <pre><code>import requests
  import json
  yo = 1
  switchPost = &quot;http://192.168.0.104:7896/iot/d?k=123456789&amp;i=san_1_switch&amp;d=sw|{}&quot;
  robGet = &quot;http://192.168.0.109:10100/robot/sen_2&quot;
  
  r = requests.get(robGet, headers={&quot;content-type&quot;:&quot;application/json&quot;})
  resp = json.loads(r.text)
  
  for attrs in (resp['attributes']['value']):
      if attrs['data'] == false:
          yo = 100
          break
      
  g = requests.post(switchPost.format(yo), headers={&quot;content-type&quot;:&quot;text/plain&quot;})
  print(r.text)
  </code></pre>
  <p>Unfortunately, the error I receive is the following:</p>
  <blockquote>
  <p>for attrs in (resp['attributes']['value']):</p>
  <p>TypeError: list indices must be integers, not str</p>
  </blockquote>