MongoDB query syntax error
<p>I've run into an issue when querying a collection I've made of Twitch JSON objects. However, the following query throws "SyntaxError: invalid syntax".</p>

<pre><code>objflat = db.twitchstreams.find({'_links': [
    'streams': [
        {'channel': 
            {'game': gameName}
        }
    ]
})
</code></pre>

<p>Any suggestions? I have all my fields in quotes, aside from gameName, which is a variable pulled from a config file of games for which I want data.</p>

<p>In your nested data structure you do have a syntax error after 'streams'.  A list only takes elements, not key/value pairs.  </p>

<p>Example below is using IPython:</p>

<p>This works:</p>

<pre><code>In [5]: {"foo":["bar"]}
</code></pre>

<p>This doesn't:</p>

<pre><code>In [6]: {"foo":["bar": 1]}
  File "&lt;ipython-input-6-28ac5b9a1b6d&gt;", line 1
{"foo":["bar": 1]}
             ^
</code></pre>

<p>SyntaxError: invalid syntax</p>

python json mongodb twitch