json dump throws type-error when using skip-keys=True

Viewed 22

i'm working with some custom objecttypes from a shipping service we use at work. i'm adding them to dictionaries in python because i need to use the information, but later when i log i don't need those objects - i want to export a json ommiting those objects.

atm i'm doing i'm copying the dict to another dict and skipping the fields

new_out = {}
exclude_keys = [address_object_field, date_object_field, service_object_field]
for count, (key, shipment) in enumerate(manifest.items()):
    output = {k: shipment[k] for k in set(list(shipment.keys())) - set(exclude_keys)}
    date_blah = str(datetime.date.today())
    new_out.update({date_blah+"-"+str(count+1).zfill(2): output})
json.dump(new_out, f, skipkeys=True)

if i try to json-ify and write the dictionary i get type-error, regardless of skipkeys

json.dump(manifest, f, skipkeys=True)

am i being stupid, or does skipkeys not always work?

0 Answers
Related