I've been struggling to parse a basic array response.
My input JSON, has a list of consistent types of structures.
[
{
"amount":"6.40000000",
"date":"1439165701",
"price":"350.26",
"tid":104159
},
{
"amount":"0.10025000",
"date":"1439162764",
"price":"351.03",
"tid":104150
}
]
My struct has a nested array struct.
type TransactionResponse struct {
Transaction []Transaction
}
type Transaction struct {
Amount string `json:"amount"`
Date string `json:"date"`
Price string `json:"price"`
tid uint `json:"tid"`
}
Function to parse the json:
func main() {
var transactions TransactionResponse
body, err := http.Get(url)
err = json.Unmarshal(body, &transactions)
}
Where am I going wrong?