def get_from_object(obj, attribute): """Gets data from a dictionary using a dotted accessor-string""" jsonpath_expr = parse_path(attribute) return_list = [i.value for i in jsonpath_expr.find(obj)] if return_list: return return_list[0] return None
def get_from_object(obj, attribute): """Gets data from a dictionary using a dotted accessor-string""" jsonpath_expr = parse_path(attribute) return_list = [i.value for i in jsonpath_expr.find(obj)] if return_list: return return_list[0] else: raise AttributeError('Attribute not found: {0}'.format(attribute))