<gh_stars>1-10
import json


class NumpyEncoder(json.JSONEncoder):
    # def default(self, obj):
    #     if isinstance(obj, np.ndarray):
    #         return obj.tolist()
    #     return json.JSONEncoder.default(self, obj)
    def default(self, o):
        try:
            iterable = iter(o)
        except TypeError:
            pass
        else:
            return list(iterable)
        # Let the base class default method raise the TypeError
        return json.JSONEncoder.default(self, o)

import json


class NumpyEncoder(json.JSONEncoder):
    # def default(self, obj):
    #     if isinstance(obj, np.ndarray):
    #         return obj.tolist()
    #     return json.JSONEncoder.default(self, obj)
    def default(self, o):
        try:
            iterable = iter(o)
        except TypeError:
            pass
        else:
            return list(iterable)
        # Let the base class default method raise the TypeError
        return json.JSONEncoder.default(self, o)
# def default(self, obj): #     if isinstance(obj, np.ndarray): #         return obj.tolist() #     return json.JSONEncoder.default(self, obj) # Let the base class default method raise the TypeError