Type/to search
0
Follow
0
Followers
Seorang pemula bertanya tentang masalah pengisihan json
Help
Created 2020-11-13 10:24:32  
 2
 1202
exchange.IO("base", "https://www.alphavantage.co/") var data = exchange.IO("api", "GET", "query?function=TIME_SERIES_DAILY_ADJUSTED&symbol=IBM&apikey=demo"); var records = data["Time Series (Daily)"];

Untuk mengakses API ini, anda akan mendapat json, rekod yang mempunyai struktur data seperti ini, anda dapat melihat bahawa kunci adalah tarikh, tetapi tidak teratur:

{
"2020-09-09": {
"7. dividend amount": "0.0000",
"8. split coefficient": "1.0",
"1. open": "122.1300",
"2. high": "123.7000",
"3. low": "121.2900",
"4. close": "122.2600",
"5. adjusted close": "120.5590",
"6. volume": "3770678"
},
"2020-08-11": {
"6. volume": "5001176",
"7. dividend amount": "0.0000",
"8. split coefficient": "1.0",
"1. open": "128.7600",
"2. high": "130.4700",
"3. low": "126.6100",
"4. close": "126.7500",
"5. adjusted close": "124.9866"
},
……

Tetapi jika anda mengaksesnya secara langsung melalui pelayar:https://www.alphavantage.co/query?function=TIME_SERIES_DAILY_ADJUSTED&symbol=IBM&apikey=demo

Key diletakkan mengikut tarikh:

"Time Series (Daily)": {
"2020-11-12": {
"1. open": "115.6300",
"2. high": "116.3700",
"3. low": "113.4800",
"4. close": "114.5000",
"5. adjusted close": "114.5000",
"6. volume": "6427016",
"7. dividend amount": "0.0000",
"8. split coefficient": "1.0"
},
"2020-11-11": {
"1. open": "118.1200",
"2. high": "118.3500",
"3. low": "116.2200",
"4. close": "117.2000",
"5. adjusted close": "117.2000",
"6. volume": "4289601",
"7. dividend amount": "0.0000",
"8. split coefficient": "1.0"
},
...
Apa yang perlu dilakukan jika anda ingin mengubah json yang dikembalikan oleh api ke dalam sebuah array yang teratur, seperti fmz dalam struktur data exchange.GetRecords?

Related Recommendations
Comment
All comments (2)

    已经解决,谢谢。

    6 years ago

    搜索 js object sort by key

    6 years ago
  • 1
iPhone Download
Forums
PINE Language
© 2015 - ∞ INVENTOR PTE LTD (SG)