stone_serializers.py 文件源码

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

项目:drupebox 作者: duncanhawthorne 项目源码 文件源码
def json_compat_obj_encode(
        data_type, obj, alias_validators=None, old_style=False,
        for_msgpack=False):
    """Encodes an object into a JSON-compatible dict based on its type.

    Args:
        data_type (Validator): Validator for obj.
        obj (object): Object to be serialized.

    Returns:
        An object that when passed to json.dumps() will produce a string
        giving the JSON-encoded object.

    See json_encode() for additional information about validation.
    """
    serializer = StoneToPythonPrimitiveSerializer(alias_validators, for_msgpack, old_style)
    return serializer.encode(data_type, obj)

# --------------------------------------------------------------
# JSON Decoder
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号