I am new to go , I am trying to extract specific key from the json structure as below.
{
"cluster_name": "escluster",
"nodes": {
"Sd2AvEXsswjTn6ErRYjg": {
"timestamp": 1460624696217,
"name": "master1",
"transport_address": "10.0.0.1:9300",
"host": "10.0.0.1:9300",
"ip": [
"10.0.0.1:9300",
"NONE"
],
"attributes": {
"data": "false",
"master": "true"
},
"os": {
"timestamp": 1460624696217,
"cpu_percent": 0,
"load_average": 0,
"mem": {
"total_in_bytes": 163987664,
"free_in_bytes": 136357264,
"used_in_bytes": 26629400,
"free_percent": 84,
"used_percent": 16
},
"swap": {
"total_in_bytes": 0,
"free_in_bytes": 0,
"used_in_bytes": 0
}
}
},
"yzabB-OaTfOqvgAELIMq1Q": {
"timestamp": 1460624938213,
"name": "data_1",
"transport_address": "10.0.0.2:9300",
"host": "10.0.0.2",
"ip": [
"10.0.0.2:9300",
"NONE"
],
"attributes": {
"master": "false"
},
"os": {
"timestamp": 1460624938213,
"cpu_percent": 0,
"load_average": 0.29,
"mem": {
"total_in_bytes": 623840000,
"free_in_bytes": 4127648,
"used_in_bytes": 666012352,
"free_percent": 1,
"used_percent": 99
},
"swap": {
"total_in_bytes": 0,
"free_in_bytes": 0,
"used_in_bytes": 0
}
}
},
"q5CdgUF2TRewujr-0RPMgQ": {
"timestamp": 1460624934417,
"name": "master_0",
"transport_address": "10.0.0.3:9300",
"host": "10.0.0.2",
"ip": [
"10.0.0.3:9300",
"NONE"
],
"attributes": {
"data": "false",
"master": "true"
},
"os": {
"timestamp": 1460624934417,
"cpu_percent": 0,
"load_average": 0,
"mem": {
"total_in_bytes": 163898764,
"free_in_bytes": 139705616,
"used_in_bytes": 24194588,
"free_percent": 85,
"used_percent": 15
},
"swap": {
"total_in_bytes": 0,
"free_in_bytes": 0,
"used_in_bytes": 0
}
}
}
}
}
As the node names are dynamic, I would like to retrieve mem for each node. I found this to retrieve data but its not dynamic key. How can we do this in go.