from json import JSONDecodeError, loads
from typing import Any


def decode_attrs(attrs: Any) -> Any:
    """Try to decode attributes as json if possible,
    otherwise return the attrs as they are

    Parameters
    ----------
    attrs: Any
        an object containing attributes

    Returns
    ----------
    Any
        either the attributes as json or the attributes as received
    """

    try:
        attrs = loads(attrs)
    except (JSONDecodeError, TypeError):
        return attrs