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
评论列表
文章目录