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