douge7771 2018-02-09 11:43
浏览 130
已采纳

golang从json仅获取一个统计信息

i tried to get one stat from web api request in json. This is what called https://api.coinmarketcap.com/v1/ticker/ethereum/

I use this github code example // Get info about coin

coinInfo, err := coinApi.GetCoinData("ethereum")
if err != nil {
    log.Println(err)
} else {
    fmt.Println(coinInfo)
}

My result in log says

{ethereum Ethereum ETH 2 830.48 0.100287 3.23573e+09 8.0977392218e+10 9.7506734e+07 9.7506734e+07 0.61 -0.65 -7.36 1518176353}

But i want only the price_usd if you look at the api domain. Why cannot get only price? Already tried coinInfo['price_usd'] but its all not working

Here you find the functions to run the GetCoinData https://github.com/miguelmota/go-coinmarketcap/blob/master/coinmarketcap.go

Can someone help me to get only the price_usd from api in golang?

  • 写回答

1条回答 默认 最新

  • dszpyf4859 2018-02-09 11:46
    关注

    According to the docs, you can use the PriceUsd field of the Coin type for this.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 MCNP里如何定义多个源?
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 请问这个是什么意思?
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏