def default(self, obj):
        if isinstance(obj, datetime):
            return obj.isoformat()
        elif hasattr(obj, 'as_dict'):
            return obj.as_dict()

        try:
            return json.JSONEncoder.default(self, obj)
        except TypeError:
            # If the JSON serializer couldn't serialize it
            # it might be a generator, convert it to a list
            try:
                return [self.default(child_obj)
                        for child_obj in obj]
            except TypeError:
                # Ok, we're lost, cause the original error
                return json.JSONEncoder.default(self, obj)
Render special active items
dataset/ETHPy150Open home-assistant/home-assistant/homeassistant/remote.py/JSONEncoder.default--crossover with--dataset/ETHPy150Open sahana/eden/modules/templates/DRK/layouts.py/S3MainMenuLayout.checkbox_item