comparison configmix/json.py @ 134:2f2e819e8d17

Check the return type of the JSON and YAML loading functions: they must be a dict alike
author Franz Glasner <hg@dom66.de>
date Thu, 05 Apr 2018 09:12:29 +0200
parents df60417d7665
children e84870359e1a
comparison
equal deleted inserted replaced
133:05cb18c8697a 134:2f2e819e8d17
51 "strict": False 51 "strict": False
52 } 52 }
53 if _with_object_pairs_hook: 53 if _with_object_pairs_hook:
54 kwds["object_pairs_hook"] = DictImpl 54 kwds["object_pairs_hook"] = DictImpl
55 decoder = json.decoder.JSONDecoder(**kwds) 55 decoder = json.decoder.JSONDecoder(**kwds)
56 return decoder.decode(jsfp.read()) 56 data = decoder.decode(jsfp.read())
57 if not isinstance(data, DictImpl):
58 raise TypeError("JSON root must be an object")
59 return data