Exclude empty/null values from JSON serialization
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. “”” # 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: del … Read more