def from_json(cls, doc):
        """
        Deserialize JSON document (string) to datetime.timedelta instance
        """
        if not isinstance(doc, basestring):
            raise TypeError("JSON document must be a string")
        match = cls.PATTERN.match(doc)
        if not match:
            raise ValueError("JSON document must match expected pattern")
        days, seconds, microseconds = map(int, match.groups())
        return timedelta(days, seconds, microseconds)
def from_json ( cls , doc ) : if not isinstance ( doc , basestring ) : raise TypeError ( "JSON document must be a string" ) match = cls . PATTERN . match ( doc ) if not match : raise ValueError ( "JSON document must match expected pattern" ) days , seconds , microseconds = map ( int , match . groups ( ) ) return timedelta ( days , seconds , microseconds )
Deserialize JSON document (string) to datetime.timedelta instance