Internal function that will be passed to the native `json.dumps`.

    This function uses the `REGISTRY` of serializers and try to convert
    a given instance to an object that json.dumps can understand.

def _converter(data):
    """Internal function that will be passed to the native `json.dumps`.

    This function uses the `REGISTRY` of serializers and try to convert
    a given instance to an object that json.dumps can understand.
    """
    handler = REGISTRY.get(data.__class__)
    if handler:
        full_name = '{}.{}'.format(
            data.__class__.__module__,
            data.__class__.__name__)
        return {
            '__class__': full_name,
            '__value__': handler(data),
        }
    raise TypeError(repr(data) + " is not JSON serializable")