views:

32

answers:

1

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.

+1  A: 

I think what you might be looking for is the unpicklable arguemnt (see http://jsonpickle.github.com/api.html#jsonpickle-high-level-api 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.

Anatoly Fayngelerin