I'm trying to find the best way to map a TypeScript array of multiple values to a struct in Go. What do you recommend?
data: [number, number, number, string, string, boolean, [string, number]?][];
This is the data in JSON format:
{
"data": [
[
35241,
7753,
7750,
"0xbb2b8038a1640196fbe3e38816f3e67cba72d940",
"spot",
true
],
[60259, 7746, null, "#7746/USD", "internal", true, ["requote", 145]]
]
}
For now, what I'm doing is unmarshaling it into a struct using interface{}
Data [][]interface{} `json:"data"`
But then I have to do a type assertion for every field
for _, asset := range assetsAndPairs.Data.Pairs.Data {
fmt.Println(asset[0].(float64))
}
Wondering if there is a better way.