import json


def jsonify_survey_results(results):
    """ Transforms output of get_survey_results into a list that javascript can actually handle. """
    return_data = []
    for pair in results:
        coordinates = [json.dumps(coordinate) for coordinate in pair[1]]
        # javascript understands json null/none values but not python Nones,
        # to handle this we must dump all variables individually
        return_data.append([json.dumps(pair[0]), coordinates])
    return return_data