[英]Api data extraction
I am using an API and I get this result when i use the getJSON method. 我使用的是API,当我使用getJSON方法时会得到此结果。 I have tried it in my codepen console and i get the same data but for some reason I can't figure out how to get to a specific text in the data.
我已经在Codepen控制台中进行了尝试,但我得到了相同的数据,但是由于某种原因,我无法弄清楚如何获取数据中的特定文本。 so for example: console.log(data) gives me the entire result below.
因此,例如:console.log(data)给了我下面的整个结果。 how do i make it give me just the exchange rate.
我如何使它只给我汇率。
console.log(data[1][4])
i've tried several methods still failing. console.log(data[1][4])
我尝试了几种仍然失败的方法。
{
"Realtime Currency Exchange Rate": {
"1. From_Currency Code": "USD",
"2. From_Currency Name": "United States Dollar",
"3. To_Currency Code": "JPY",
"4. To_Currency Name": "Japanese Yen",
"5. Exchange Rate": "111.28450000",
"6. Last Refreshed": "2017-11-23 00:24:23",
"7. Time Zone": "UTC"
}
}
What I've got in my JS: 我的JS中有什么:
$.getJSON(realtime, function(data) {
console.log(data);
});
Try this : 尝试这个 :
data["Realtime Currency Exchange Rate"]
and data["Realtime Currency Exchange Rate"]
和
data["Realtime Currency Exchange Rate"]["From_Currency Code"]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.