code: def loadstr(cls, string):
          
          try:
              string = string.decode('utf-8')
          except AttributeError:
              pass
  
          lexer = tokenizer(string)
  
          if cls.is_molfile(string):
              molfile = Molfile()
  
              try:
                  molfile.update(json.loads(string))
              except ValueError:
                  molfile._build(lexer)
              return molfile
  
          elif cls.is_sdfile(string):
              sdfile = SDfile()
  
              try:
                  sdfile.update(json.loads(string))
              except ValueError:
                  sdfile._build(lexer)
              return sdfile
  
          else:
              raise ValueError('Cannot determine the format of string.')
docs: Load data into ``CTfile`` object from string.
          
          :param str string: String containing data in ``CTfile`` format.
          :return: Instance of ``CTfile``.