code: def write_offsets_to_file(cls, json_file_name, consumer_offsets_data):
          
          # Save consumer-offsets to file
          with open(json_file_name, "w") as json_file:
              try:
                  json.dump(consumer_offsets_data, json_file)
              except ValueError:
                  print("Error: Invalid json data {data}".format(data=consumer_offsets_data))
                  raise
              print("Consumer offset data saved in json-file {file}".format(file=json_file_name))
docs: Save built consumer-offsets data to given json file.