1
0
mirror of https://github.com/haiwen/libsearpc.git synced 2025-09-01 12:56:32 +00:00

Added json encoder to searpc object

This commit is contained in:
zhengxie
2013-02-20 16:42:33 +08:00
parent 8e908095d1
commit 493d1c95a9
2 changed files with 7 additions and 2 deletions

View File

@@ -8,7 +8,6 @@ class SearpcError(Exception):
def __str__(self):
return self.msg
def _fret_int(ret_str):
try:
dicts = json.loads(ret_str)
@@ -57,6 +56,12 @@ class _SearpcObj(object):
except:
return None
class SearpcObjEncoder(json.JSONEncoder):
def default(self, obj):
if not isinstance(obj, _SearpcObj):
return super(_SearpcObjEncoder, self).default(obj)
return obj._dict
def _fret_obj(ret_str):
try:
dicts = json.loads(ret_str)