blob: d5bec53580b9909ed8a378fdbe51c1761197e6cf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# -*- coding: utf-8 -*-
import inspect
from json import JSONEncoder
def is_not_method(o):
return not inspect.isroutine(o)
class ObjectJSONEncoder(JSONEncoder):
def default(self, reject):
non_methods = inspect.getmembers(reject, is_not_method)
return {attr: value for attr, value in non_methods
if (not attr.startswith('__')
and attr != 'when'
and attr != 'now')}
|