mirror of
https://github.com/haiwen/libsearpc.git
synced 2025-09-05 14:50:38 +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):
|
def __str__(self):
|
||||||
return self.msg
|
return self.msg
|
||||||
|
|
||||||
|
|
||||||
def _fret_int(ret_str):
|
def _fret_int(ret_str):
|
||||||
try:
|
try:
|
||||||
dicts = json.loads(ret_str)
|
dicts = json.loads(ret_str)
|
||||||
@@ -57,6 +56,12 @@ class _SearpcObj(object):
|
|||||||
except:
|
except:
|
||||||
return None
|
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):
|
def _fret_obj(ret_str):
|
||||||
try:
|
try:
|
||||||
dicts = json.loads(ret_str)
|
dicts = json.loads(ret_str)
|
||||||
|
Reference in New Issue
Block a user