开发者

excluding fields from json serialization in python using jsonpickle

I am using jsonpickle to serialize an object to json. The object has certain开发者_高级运维 fields that point to other objects. I'd like to selectively not include those in the serialization, so that the resulting json file is essentially pure human-readable text without any funny representations of objects. Is there a way to make jsonpickle ignore certain object fields when serialization? Or more generally, include only fields that are "primitive" or easily serializable fields, like dictionaries, ints, lists of dicts, etc.

thanks.


I think what you might be looking for is the unpicklable argument (see this doc for details). In short, if this argument is set to False, jsonpickle will not output custom python classes to JSON. It should only output JSON native types e.g strings, ints, bools and lists.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜