def default( self, o ):
if isinstance(o, datetime):<EOL><INDENT>return o.isoformat()<EOL><DEDENT>else:<EOL><INDENT>if isinstance(o, Exception):<EOL><INDENT>return str(o)<EOL><DEDENT>else:<EOL><INDENT>if isinstance(o, numpy.integer):<EOL><INDENT>return int(o)<EOL><DEDENT>else:<EOL><INDENT>return super(MetadataEncoder, self).default(o)<EOL><DEDENT><DEDENT><DEDENT>
If o is a datetime object, convert it to an ISO string. If it is an
        exception, convert it to a string. If it is a numpy int, coerce it to
        a Python int.

        :param o: the field to serialise
        :returns: a string encoding of the field