mirror of
https://github.com/haiwen/libsearpc.git
synced 2025-09-04 06:14:55 +00:00
Added json encoder to searpc object
This commit is contained in:
@@ -1,2 +1,2 @@
|
||||
|
||||
from client import SearpcClient, searpc_func, SearpcError
|
||||
from client import SearpcClient, searpc_func, SearpcError, SearpcObjEncoder
|
||||
|
@@ -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)
|
||||
|
Reference in New Issue
Block a user