Stacking to_object and from_object decorators.
This kind of bothers me
@to_object()
@from_object()
class Foo(object):
pass
The decorators are separate because each accepts arguments that modify the encode/decode behavior of the object. Stil, there is something about the above code I dislike. So how about something like this
@jsonable
class Foo(object):
pass
jsonable accepts no arguments. If you want to pass arguments then you must still use from_object and to_object. Essentially jsonable becomes a short cut for the first example. Its implementation being quite simple
def jsonable(cls):
to_object()(cls)
from_object()(cls)
Is this use case common enough to warrant the additional of jsonable?
:+1: I think that in complex projects when you have a lot of DB models, it would be useful to put only jsonable instead of @to_object/@from_object.
20 lines of @to_object/@from_object are now 10 lines of jsonable, more readable and more dev-friendly, imo.