刚刚开始将我的 python 代码转换为 Go,但是在 json 操作上有一些问题......这是我目前的代码
package test
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"strings"
"time"
)
type Collection struct {
Contract string
}
type Data struct {
Activity Activity `json:"activity"`
}
type Activity struct {
Activities Activities `json:"activities"`
HasMore bool `json:"hasMore"`
}
type Activities []Sale
type Sale struct {
From string `json:"from"`
From_login string `json:"from_login"`
To string `json:"to"`
To_login string `json:"to_login"`
Transaction_hash string `json:"transaction_hash"`
Timestamp int `json:"timestamp"`
Types string `json:"type"`
Price float32 `json:"price"`
Quantity string `json:"quantity"`
Nft Nft `json:"nft"`
Attributes string `json:"attributes"`
Collection CollectionStruct `json:"collection"`
}
type Nft struct {
Name string `json:"name"`
Thumbnail string `json:"thumbnail"`
Asset_id string `json:"asset_id"`
Collection NftCollection `json:"collection"`
}
type NftCollection struct {
Avatar string `json:"avatar"`
Name string `json:"name"`
Certified bool `json:"certified"`
}
type CollectionStruct struct {
Avatar string `json:"avatar"`
Address string `json:"address"`
Name string `json:"name"`
Certified bool `json:"certified"`
}
}
我不明白为什么我的 Sale 结构是空的:/我创建了所有这些结构以使用 Unmarshal 以便我可以循环。我检查了返回的 json 的结构并复制了它我确定我错过了一些东西但不知道是什么
梵蒂冈之花
喵喔喔
相关分类