title: Parsing JSON in go
body: <p>My question is about parsing JSON files in golang. </p>
  
  <p>Specifically, I am trying to parse output of a command "docker network inspect bridge", which happens to be in JSON format. The command is described here. My goal is to get a list of "IPv4Address" for the listed containers. </p>
  
  <p>I have tried to do this but failing to convert map[string]interface{} to map[string]string. My code is here:- <a href="https://play.golang.org/p/eO_j996gGb" rel="nofollow">https://play.golang.org/p/eO_j996gGb</a> </p>
  
  <pre><code>$ sudo docker network inspect bridge
  [
      {
          "Name": "bridge",
          "Id": "b2b1a2cba717161d984383fd68218cf70bbbd17d328496885f7c921333228b0f",
          "Scope": "local",
          "Driver": "bridge",
          "IPAM": {
              "Driver": "default",
              "Config": [
                  {
                      "Subnet": "172.17.42.1/16",
                      "Gateway": "172.17.42.1"
                  }
              ]
          },
          "Internal": false,
          "Containers": {
              "bda12f8922785d1f160be70736f26c1e331ab8aaf8ed8d56728508f2e2fd4727": {
                  "Name": "container2",
                  "EndpointID": "0aebb8fcd2b282abe1365979536f21ee4ceaf3ed56177c628eae9f706e00e019",
                  "MacAddress": "02:42:ac:11:00:02",
                  "IPv4Address": "172.17.0.2/16",
                  "IPv6Address": ""
              },
              "f2870c98fd504370fb86e59f32cd0753b1ac9b69b7d80566ffc7192a82b3ed27": {
                  "Name": "container1",
                  "EndpointID": "a00676d9c91a96bbe5bcfb34f705387a33d7cc365bac1a29e4e9728df92d10ad",
                  "MacAddress": "02:42:ac:11:00:01",
                  "IPv4Address": "172.17.0.1/16",
                  "IPv6Address": ""
              }
          },
          "Options": {
              "com.docker.network.bridge.default_bridge": "true",
              "com.docker.network.bridge.enable_icc": "true",
              "com.docker.network.bridge.enable_ip_masquerade": "true",
              "com.docker.network.bridge.host_binding_ipv4": "0.0.0.0",
              "com.docker.network.bridge.name": "docker0",
              "com.docker.network.driver.mtu": "1500"
          }
      }
  ]
  </code></pre>
  
  <p>What is the correct way to parse such JSON files in golang. I did try using type conversion but doesn't help. I have tried many things but finally could only get as far as the code shown in the snippet. How can I extract the IPv4Address field from the "cont" object? </p>
  
  <p>Link to go playground snippet I have is <a href="https://play.golang.org/p/eO_j996gGb" rel="nofollow">https://play.golang.org/p/eO_j996gGb</a>. Any help is greatly appreciated (willing to try things out, don't need just the code but ideas :) Thanks. </p>