如何使用Rest Assured从Json响应中获取NetworkID

时间:2018-03-16 08:20:16

标签: java rest rest-assured rest-assured-jsonpath

{
    "Image": "sha256:357a02cbb63175a797ea238665bd1cfe6210f0381670d7155b034a58020a65f5",
    "NetworkSettings": {
        "IPAddress": "172.17.0.6",
        "IPPrefixLen": 16,
        "Gateway": "172.17.0.1",
        "Bridge": "",
        "PortMapping": null,
        "Ports": {
            "80/tcp": [],
            "8082/tcp": []
        },
        "MacAddress": "02:42:ac:11:00:06",
        "Networks": {
            "bridge": {
                "Aliases": null,
                "NetworkID": "08a5829cf9c451ad09c28ce5c0ab09a192e7adf845563cec4f726572d91835be",
                "EndpointID": "7f8c27eaf162c95ca932b343739bb4e08dd5efb73aa2454db64618a9b62f417e",
                "Gateway": "172.17.0.1",
                "IPAddress": "172.17.0.6",
                "IPPrefixLen": 16,
                "IPv6Gateway": "",
                "GlobalIPv6Address": "",
                "GlobalIPv6PrefixLen": 0,
                "MacAddress": "02:42:ac:11:00:06"
            }
        }
    }
}

我试过以下方式,第一行给出空白输出第二行代码打印网络设置,空白网络ID。

String networkId = response.jsonPath()。getString(“NetworkSettings.Networks.bridge.NetworkID”);

String networkId = response.jsonPath()。getString(“NetworkSettings);

0 个答案:

没有答案