code: def to_json(self, path, root_array=True, mode=WRITE_MODE, compression=None):
          
          with universal_write_open(path, mode=mode, compression=compression) as output:
              if root_array:
                  json.dump(self.to_list(), output)
              else:
                  json.dump(self.to_dict(), output)
docs: Saves the sequence to a json file. If root_array is True, then the sequence will be written
          to json with an array at the root. If it is False, then the sequence will be converted from
          a sequence of (Key, Value) pairs to a dictionary so that the json root is a dictionary.
  
          :param path: path to write file
          :param root_array: write json root as an array or dictionary
          :param mode: file open mode