import json


def json_encoder(obj):
    """
    JSON encoder that converts non serializable objects to null.

    :param obj: Object to encode
    :return: Serializable object with non-serializable objects converted to null
    """
    try:
        json.dumps(obj)
        return obj
    except Exception as e:
        return None