You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
What's a good way of skipping a member when serializing a response object?
Say I've got a class:
and I want to serialize an instance of
Person
as part of a response, but I don't want to includesecret
.A couple potential solutions I can think of:
secret
in the response spec, but turn off strict validationsecret
, then returnPerson
's__format__
function to skipsecret
, which will eventually get called byjson.dumps
secret
when it encounters an instance ofPerson
I don't like (1) because it requires turning of strict validation. (2) and (3) would work but are rather inelegant. I'm leaning most toward (4).
Any thoughts?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions