I am new to the Golang world and trying to parse a json
response returned by AWS API.
I've tried parsing the result by dot notation and seem to get success in the higher levels. Below is what my experimentation resulted to.
For brevity I excluded other fields
Test 1
fmt.Println(result)
returns
{
DBClusterSnapshots: [{
Status: "available"
}]
}
Test 2
fmt.Println(result.DBClusterSnapshots[0])
returns
{
Status: "available"
}
Test 3
fmt.Println(result.DBClusterSnapshots[0].Status)
returns what seem to be a reference to an object
0xc0001e74c8
Given the last example (Test 3) how do I parse it properly to get the value of Status
which is "available"
As pointed out by @mkopriva
Status
is a pointer and therefore need to be dereference when intending to extract the string.
so to achieve extracting the value of status we can dereference it like this.
s := *result.DBClusterSnapshots[0].Status
fmt.Println(s)