APIHelper.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:flowroute-numbers-python 作者: flowroute 项目源码 文件源码
def json_serialize(obj):
        """JSON Serialization of a given object.

        Args:
            obj (object): The object to serialise.

        Returns:
            str: The JSON serialized string of the object.

        """
        if obj is None:
            return None

        # Resolve any Names if it's one of our objects that needs to have this called on
        if isinstance(obj, list):
            value = list()

            for item in obj:
                try:
                    value.append(item.resolve_names())
                except (AttributeError, TypeError):
                    value.append(item)

            obj = value
        else:
            try:
                obj = obj.resolve_names()
            except (AttributeError, TypeError):
                obj = obj

        return jsonpickle.encode(obj, False)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号