from typing import Union
from typing import Dict


def form_store(
        payload: Union[Dict, str],
        metadata: Union[Dict, str, None],
):
    """
    Processes the payload and the metadata (if any exists) into a JSON-like format.

    :param payload: A string object or dictionary containing the message data.
    :param metadata: A dictionary containing the message metadata.
    :return: A dictionary with "DATA" and (optionally) "METADATA" fields.
    """

    data = {"DATA": payload}

    if metadata:
        data["METADATA"] = metadata

    return data