def topic_ref_transform(ref_string, topic):
    """
    Converts a topic string with forward-slashes into a JSON reference-friendly format
    ("/" becomes "~1"), then places the new string into the provided base reference path.

    :param ref_string: The base reference path
    :param topic: The DXL topic string to convert
    """
    return str(ref_string.format(topic.replace("/", "~1")))