-1

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".

objflat = db.twitchstreams.find({'_links': [
    'streams': [
        {'channel': 
            {'game': gameName}
        }
    ]
})

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.

1 Answers1

0

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

Example below is using IPython:

This works:

In [5]: {"foo":["bar"]}

This doesn't:

In [6]: {"foo":["bar": 1]}
  File "<ipython-input-6-28ac5b9a1b6d>", line 1
{"foo":["bar": 1]}
             ^

SyntaxError: invalid syntax

Noah Gift
  • 256
  • 1
  • 4
  • 9