Hi I am using a JSON Encoder, where pickle.dumps() is giving me weird output. The output is coming as:
"cdecimal Decimal p0 (S'2097369' p1 tp2 Rp3 .",
While, it should be: 2097369
The code snippet is:
class PythonObjectEncoder(JSONEncoder):
def default(self, obj):
if isinstance(obj, (list, dict, unicode, int, float, str, bool, type(None))):
return JSONEncoder.default(self, obj)
return pickle.dumps(obj)
def as_python_object(dct):
if '_python_object' in dct:
return pickle.loads('')
return dct
Can anyone tell me what is going wrong and how can I get back the desired value?