def adjust_json_from_docker(json_rep):
    """If the json comes from a docker call, we need to adjust it to make use
    of it. """
    if not isinstance(json_rep[0]['NetworkSettings']['Ports'], dict):
        raise Exception(
            "Error parsing docker engine inspection JSON structure, try to specify container engine using '--container-engine' parameter"
            )
    for item in json_rep[0]['Mounts']:
        item['source'] = item['Source']
        if item['Mode'] == 'rw':
            item['options'] = 'rw'
        if item['Mode'] == 'ro':
            item['options'] = 'ro'
    temp_ports = []
    for item in json_rep[0]['NetworkSettings']['Ports']:
        container_port = item.split('/')
        host_port = json_rep[0]['NetworkSettings']['Ports'][item][0]['HostPort'
            ]
        new_port = {'hostPort': int(host_port), 'protocol': container_port[1]}
        temp_ports.append(new_port)
    del json_rep[0]['NetworkSettings']['Ports']
    json_rep[0]['NetworkSettings']['Ports'] = temp_ports
