如何从我的JSON打印美元价格?

时间:2018-03-28 04:31:03

标签: arrays json arraylist

我有这样的数据

[
{
    "id": "ethereum", 
    "name": "Ethereum", 
    "symbol": "ETH", 
    "rank": "2", 
    "price_usd": "449.935", 
    "price_btc": "0.0574132", 
    "24h_volume_usd": "1632850000.0", 
    "market_cap_usd": "44300619222.0", 
    "available_supply": "98460042.0", 
    "total_supply": "98460042.0", 
    "max_supply": null, 
    "percent_change_1h": "0.11", 
    "percent_change_24h": "-2.69", 
    "percent_change_7d": "-21.25", 
    "last_updated": "1522211054"
}

任何人都可以帮我打印美元价格?像这样... 美元价格:449.935

1 个答案:

答案 0 :(得分:1)

我认为你只是在寻找data[0].price_usd

var data = [
{
    "id": "ethereum", 
    "name": "Ethereum", 
    "symbol": "ETH", 
    "rank": "2", 
    "price_usd": "449.935", 
    "price_btc": "0.0574132", 
    "24h_volume_usd": "1632850000.0", 
    "market_cap_usd": "44300619222.0", 
    "available_supply": "98460042.0", 
    "total_supply": "98460042.0", 
    "max_supply": null, 
    "percent_change_1h": "0.11", 
    "percent_change_24h": "-2.69", 
    "percent_change_7d": "-21.25", 
    "last_updated": "1522211054"
}];

console.log('USD Price: ' + data[0].price_usd);