import json


def get_raw_metrics_from_file(filename):
    """
    Parse the given file as JSON and return a dictionary of the
    given metric names to their values.

    :param filename: JSON file name.
    :return: Dictionary of {beanName.metricName->Value}.
    """
    values = {}
    with open(filename) as mf:
        try:
            j = json.load(mf)
        except json.decoder.JSONDecodeError:
            print("WARNING: Failed to decode {} as valid json".format(filename))
            return values

    for bean in j['beans']:
        for m in bean.keys():
            values[bean['name'] + ':' + m] = bean[m]
    return values