<gh_stars>0
def del_none(d):
    """
    Delete keys with the value ``None`` in a dictionary, recursively.

    This alters the input so you may wish to ``copy`` the dict first.

    Courtesy <NAME> and modified from:
    https://stackoverflow.com/questions/4255400/exclude-empty-null-values-from-json-serialization
    """
    # For Python 3, write `list(d.items())`; `d.items()` won’t work
    # For Python 2, write `d.items()`; `d.iteritems()` won’t work
    for key, value in list(d.items()):
        if value is None or (hasattr(value, '__iter__') and len(value) == 0):
            del d[key]
        elif isinstance(value, dict):
            del_none(value)
        elif isinstance(value, list):
            for item in value:
                if isinstance(item, dict):
                    del_none(item)
    return d  # For convenience

def del_none(d):
    """
    Delete keys with the value ``None`` in a dictionary, recursively.

    This alters the input so you may wish to ``copy`` the dict first.

    Courtesy <NAME> and modified from:
    https://stackoverflow.com/questions/4255400/exclude-empty-null-values-from-json-serialization
    """
    # For Python 3, write `list(d.items())`; `d.items()` won’t work
    # For Python 2, write `d.items()`; `d.iteritems()` won’t work
    for key, value in list(d.items()):
        if value is None or (hasattr(value, '__iter__') and len(value) == 0):
            del d[key]
        elif isinstance(value, dict):
            del_none(value)
        elif isinstance(value, list):
            for item in value:
                if isinstance(item, dict):
                    del_none(item)
    return d  # For convenience
Delete keys with the value ``None`` in a dictionary, recursively.      This alters the input so you may wish to ``copy`` the dict first.      Courtesy <NAME> and modified from:     https://stackoverflow.com/questions/4255400/exclude-empty-null-values-from-json-serialization # For Python 3, write `list(d.items())`; `d.items()` won’t work # For Python 2, write `d.items()`; `d.iteritems()` won’t work # For convenience