def from_json(cls, json_thing):
        """
        Given a JSON object or JSON string that was created by `self.to_json`,
        return the corresponding markovify.Chain.
        """

        if isinstance(json_thing, basestring):
            obj = json.loads(json_thing)
        else:
            obj = json_thing

        if isinstance(obj, list):
            rehydrated = dict((tuple(item[0]), item[1]) for item in obj)
        elif isinstance(obj, dict):
            rehydrated = obj
        else:
            raise ValueError("Object should be dict or list")

        state_size = len(list(rehydrated.keys())[0])

        inst = cls(None, state_size, rehydrated)
        return inst
def from_json ( cls , json_thing ) : if isinstance ( json_thing , basestring ) : obj = json . loads ( json_thing ) else : obj = json_thing if isinstance ( obj , list ) : rehydrated = dict ( ( tuple ( item [ 0 ] ) , item [ 1 ] ) for item in obj ) elif isinstance ( obj , dict ) : rehydrated = obj else : raise ValueError ( "Object should be dict or list" ) state_size = len ( list ( rehydrated . keys ( ) ) [ 0 ] ) inst = cls ( None , state_size , rehydrated ) return inst
Given a JSON object or JSON string that was created by `self.to_json`,
        return the corresponding markovify.Chain.