def json_encoder(obj):
 if isinstance(obj, datetime.datetime):
  return obj.isoformat()
 else:
  return obj

def json_encoder ( obj ) : if isinstance ( obj , datetime . datetime ) : return obj . isoformat ( ) else : return obj
json encoder that formats datetimes as iso8601 format .