import json


def parse_message(line: str) -> dict:
    """
    Given a string that looks like json with
    a 'msg' element in it, remove the msg element
    and replace it with a set of keys and values
    derived from expanding the msg field on spaces.

    For example, a line string like:
      {"one": "fish","two": "fish","msg": "red fish poop fish"}
    would produce a return dict like:
      {'one': 'fish', 'two': 'fish', 'red': 'fish', 'poop': 'fish'}
    """
    data = json.loads(line)
    message = data['msg']
    del data['msg']

    elements = message.split()
    while elements:
        key = elements.pop(0)
        if elements:
            value = elements.pop(0)
        else:
            value = ""
        data[key] = value

    return data