'Print a nicely formatted complex number, or default to the JSON encoder'

def default(self, obj):

    if isinstance(obj, complex):
        return u'{real:.7g}{imag:+.7g}*j'.format(real=obj.real, imag=obj.imag)
    return json.JSONEncoder.default(self, obj)
