import json


def parse_iperf_json_stats(fp):
    """
    Parse UDP statistics as captured by iPerf.
    :param fp: the file path that stores the iPerf statistics
    :returns a dictionary containing results
    """
    d = {}
    with open(fp) as f:
        client_data = json.load(f)
        average_bits_per_second = client_data["end"]["sum"]["bits_per_second"]
        d['average_megabits_per_second'] = float(average_bits_per_second / 1_000_000)
    return d