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:
@@ -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