Make a json-serializable type recursively read-only

    :param obj: Any json-serializable type
    :param forgive_type: If you can forgive a type to be unknown (instead of
                         raising an exception)

def make_ro(obj: Any, forgive_type=False):
    """
    Make a json-serializable type recursively read-only

    :param obj: Any json-serializable type
    :param forgive_type: If you can forgive a type to be unknown (instead of
                         raising an exception)
    """

    if isinstance(obj, (str, bytes, int, float, bool, RoDict, RoList)) \
            or obj is None:
        return obj
    elif isinstance(obj, Mapping):
        return RoDict(obj, forgive_type)
    elif isinstance(obj, Sequence):
        return RoList(obj, forgive_type)
    elif forgive_type:
        return obj
    else:
        raise ValueError('Trying to make read-only an object of type "{}"'
                         .format(obj.__class__.__name__))