def try_dict(value):
    """Try converting objects first to dict, then to str so we can easily compare them against JSON."""
    try:
        return dict(value)
    except (ValueError, TypeError):
        return str(value)