def default(self, obj):
if isinstance(obj, np.ndarray):<EOL><INDENT>return obj.tolist()<EOL><DEDENT>elif isinstance(obj, bytes):<EOL><INDENT>return obj.decode()<EOL><DEDENT>elif isinstance(obj, complex):<EOL><INDENT>return (obj.real, obj.imag)<EOL><DEDENT>elif (isinstance(obj, (float, np.float64, np.float_)) and<EOL>not np.isfinite(obj)):<EOL><INDENT>return None<EOL><DEDENT>elif isinstance(obj, (np.int8, np.int16, np.int32, np.int64)):<EOL><INDENT>return int(obj)<EOL><DEDENT>else:<EOL><INDENT>return json.JSONEncoder.default(self, obj)<EOL><DEDENT>
Overrides the default serializer for `JSONEncoder`.

        This can serialize the following objects in addition to what
        `JSONEncoder` can already do.

        - `np.array`
        - `bytes`
        - `complex`
        - `np.float64` and other `np.dtype` objects

        Parameters
        ----------

        obj : object
            A Python object to serialize to JSON.

        Returns
        -------

        str
            A JSON encoded representation of the input object.