code: def to_json(self):
          
          if self._embedding:
              warnings.warn('Serialization of attached embedding '
                            'to json is not supported. '
                            'You may serialize the embedding to a binary format '
                            'separately using vocab.embedding.serialize')
          vocab_dict = {}
          vocab_dict['idx_to_token'] = self._idx_to_token
          vocab_dict['token_to_idx'] = dict(self._token_to_idx)
          vocab_dict['reserved_tokens'] = self._reserved_tokens
          vocab_dict['unknown_token'] = self._unknown_token
          vocab_dict['padding_token'] = self._padding_token
          vocab_dict['bos_token'] = self._bos_token
          vocab_dict['eos_token'] = self._eos_token
          return json.dumps(vocab_dict)
docs: Serialize Vocab object to json string.
  
          This method does not serialize the underlying embedding.