def to_json_dict(self):
        """Gets the copy of the JSON document

        :return: the JSON document
        """
        self.check_input_fields()
        base = super(BaseAction, self).to_json_dict()
        for key, value in base.get('inputs', {}).iteritems():
            try:
                if isinstance(value, datetime.datetime):
                    base['inputs'][key] = Timestamp.to_string(value)
                elif isinstance(value, datetime.timedelta):
                    base['inputs'][key] = Duration.to_string(value)
            except TypeError as e:
                raise ValidationError(e)
        return base
Beispiel #2
0
    def to_json_dict(self):
        """Returns a copy of this Resource as a JSON dictionary.

        :return: A copy of this Resource as a JSON dictionary.
        """
        # Convert standard types to strings
        final = {}
        for key, value in self.__json.iteritems():
            try:
                if isinstance(value, datetime.datetime):
                    final[key] = Timestamp.to_string(value)
                elif isinstance(value, datetime.timedelta):
                    final[key] = Duration.to_string(value)
                else:
                    final[key] = value
            except TypeError as e:
                raise ValidationError(e)
        return final