import json


def gps_to_json(positions):
    """
    Transform GPS data to web format (time data to seconds since epoch)
    :param positions: position data received from bbgps
    :return: json data to return on request
    """
    data = []
    for position in positions:
        aux = position.copy()
        aux["time"] = int(aux["time"].strftime("%s"))
        data.append(aux)
    return json.dumps(data)