My original dictionary is
A = {
'date': datetime.date(2013, 1, 1),
'price': 100
}
Since datetime.date
is not serializable, I add a default function to deal with that:
B = json.dumps(A, default=lambda obj:obj.isoformat() if hasattr(obj, 'isoformat') else obj)
My question is, how can I deserialize the 'date'
field while I use json.loads
to convert it back to the original dictionary?