'Writes data in JSON format to a file'

def write_to_cache(self):

    data = {'data': self.data, 'inventory': self.inventory}
    json_data = json.dumps(data, sort_keys=True, indent=2)
    cache = open(self.cache_filename, 'w')
    cache.write(json_data)
    cache.close()
