def decode(string): """Converts the JSON string into a Python object. >>> str(decode('"my string"')) 'my string' >>> decode('36') 36 """ j = Unpickler() return j.restore(json.decode(string))
def loads(string): """Converts the JSON string into a Python object. >>> loads('"my string"') u'my string' >>> loads('36') 36 """ j = Unpickler() return j.restore(json.loads(string))
def test_unpickle_dict(self): expected = { 1: { "1ID": "A23", "Gender": "Male", "Age": 22, "Sales": 2445, "BMI": "normal", "salary": 20, "Birthday": "24/06/1995" }, 2: { "IhD": "A2f3", "Gender": "Male", "Age": 23, "Sales": 2565, "BMI": "normal", "salary": 20, "Birthday": "24/06/1995" }, 3: { "IjD": "Aa23", "Gender": "Female", "Age": 25, "Sales": 25, "BMI": "normal", "salary": 20, "Birthday": "24/06/1995" }, 4: { "IgD": "A23", "Gender": "Female", "Age": 26, "Sales": 225, "BMI": "normal", "salary": 20, "Birthday": "24/06/1995" } } pickle = Pickler.pickle_dictionary_values(expected) self.local.insert_dictionary(pickle) result = Unpickler.unpickle_dictionary(self.local.get_db()) self.assertEqual(expected, result)
def load(file): """Converts the JSON string in file into a Python object """ j = Unpickler() return j.restore(json.load(file))
def get_remote(self): unpickle = Unpickler.unpickle_dictionary(self.remote.get_db()) return unpickle
def get_local(self): unpickle = Unpickler.unpickle_dictionary(self.local.get_db()) return unpickle