# -*- encoding: utf-8 -*-
# -----------------------------------------------------------------------------
# @File Name  : format_transfer.py
# @Time       : 2021/1/6 下午7:58
# @Author     : X. Peng
# @Email      : acepengxiong@163.com
# @Software   : PyCharm
# -----------------------------------------------------------------------------
import decimal
import json
import numpy as np

class npEncoder(json.JSONEncoder):
    def default(self, obj):
        if isinstance(obj, np.ndarray):
            return obj.tolist()
        elif isinstance(obj, decimal.Decimal):
            return obj.__str__()
        return json.JSONEncoder.default(self, obj)