在这里,我从Api获取关闭数据,但我获得相反的数据。期待 (2021-05-07 1931.3 ) 但得到 ( 2005-08-17 534.169 ) 所以为什么我得到相反的数据,我该如何解决这个问题,帮助
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
)
type Data struct {
MetaData MetaData `json:"Meta Data"`
TimeSeriesDaily map[string]DataElement `json:"Time Series (Daily)"`
}
type MetaData struct {
OneInformation string `json:"1. Information"`
TwoSymbol string `json:"2. Symbol"`
ThreeLastRefreshed string `json:"3. Last Refreshed"`
FiveOutputSize string `json:"5. Output Size"`
SixTimeZone string `json:"6. Time Zone"`
}
type DataElement struct {
OneOpen string `json:"1. open"`
TwoHigh string `json:"2. high"`
ThreeLow string `json:"3. low"`
FourClose string `json:"4. close"`
FiveVolume string `json:"5. volume"`
}
func main() {
resp, err := http.Get("https://www.alphavantage.co/query?function=TIME_SERIES_DAILY_ADJUSTED&symbol=RELIANCE.BSE&outputsize=full&apikey=BV68V9VC5MTQFJRT")
if err != nil {
return
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Fatal(err)
}
var y Data
err = json.Unmarshal(body, &y)
if err != nil {
log.Fatal(err)
}
fmt.Println(y)
var l string
var lop string
for k, data := range y.TimeSeriesDaily {
_, lop, l = ("%s closed at %s\n"), (k), (data.FourClose)
}
fmt.Println(lop, l)
}
数据截图 - 在此处输入图像描述
MMTTMM
相关分类