简体   繁体   中英

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 eg strings, ints, bools and lists.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM