from typing import Any
import json


def is_jsonable(x: Any):
    """
    Check if an object is json serializable.
    Source: https://stackoverflow.com/a/53112659
    """
    try:
        json.dumps(x)
        return True
    except (TypeError, OverflowError):
        return False