3

how to get an clean json string using jsonpickle. the output has lots of addtional fields that not in my class,for example,"py/reduce","_state","_django_version" and so on.

i just want a clean output like this:

[
  {"name":"namevalue","id":"4","expiredtime":"2015-3-4 12:0000"},
  {"name":"namevalue2","id":"5","expiredtime":"2015-4-4 12:0000"}
]

i have tried add unpicklable=False ,but not work.

 item_list=list(ChannelItem.objects.filter(channel__id=channel_id))
 results =[jsonpickle.encode(ob,unpicklable=False) for ob in item_list]

what i have missed? does jsonpickle can't serialize an object/objectlist to an clean jsonstring that just contains the fields defined in the class? or is there an alternative package to do this?

phiree
  • 409
  • 6
  • 15

0 Answers0