diff --git a/bids/layout/models.py b/bids/layout/models.py index 0d0a625dd..ed59de67e 100644 --- a/bids/layout/models.py +++ b/bids/layout/models.py @@ -337,7 +337,10 @@ class BIDSJSONFile(BIDSFile): def get_dict(self): ''' Return the contents of the current file as a dictionary. ''' - return json.loads(self.get_json()) + d = json.loads(self.get_json()) + if not isinstance(d, dict): + raise ValueError("File %s is a json containing %s, not a dict which was expected" % (self.path, type(d))) + return d def get_json(self): ''' Return the contents of the current file as a JSON string. '''