def dumps(data, **kwargs):
    """Convert a PPMP entity to JSON. Additional arguments are the same as
    accepted by `json.dumps`."""

    def _encoder(value):
        if isinstance(value, datetime.datetime):
            return value.isoformat()

        if hasattr(value, "_data"):
            return value._data

        raise TypeError('Could not encode %r' % value)

    return json.dumps(data, default=_encoder, **kwargs)
Convert a PPMP entity to JSON. Additional arguments are the same as
    accepted by `json.dumps`.