def getJSONDictionary(filename): """ Open json file and return its dictionary """ d = None f = openFile(filename, 'r') if f: try: d = json.load(f) except Exception, e: tolog("!!WARNING!!2222!! Failed to load json dictionary: %s" % (e)) else: f.close() # Try to convert the dictionary from unicode to utf-8 if d != {}: try: d = convert(d) except Exception, e: tolog("!!WARNING!!2996!! Failed to convert dictionary from unicode to utf-8: %s, %s" % (d, e)) else:
def getJSONDictionary(filename): """ Read a dictionary with unicode to utf-8 conversion """ dictionary = None from json import load f = openFile(filename, 'r') if f: try: dictionary = load(f) except Exception, e: tolog("!!WARNING!!2222!! Failed to load json dictionary: %s" % (e)) else: f.close() # Try to convert the dictionary from unicode to utf-8 if dictionary != {}: try: dictionary = convert(dictionary) except Exception, e: tolog("!!WARNING!!2996!! Failed to convert dictionary from unicode to utf-8: %s, %s" % (dictionary, e)) else: