我想从 API 获取数据:
extern crate reqwest;
use std::io::Read;
pub fn main() {
let mut response = reqwest::get("https://api.fcoin.com/v2/market/ticker/ftbtc")
.expect("Failed to send request");
let mut buf = String::new();
response
.read_to_string(&mut buf)
.expect("Failed to read response");
println!("{}", buf);
}
输出是
{
"status": 0,
"data": {
"ticker": [
0.00006173,
500,
0.00006173,
44411.28,
0.00006174,
917.98,
0.00008033,
0.00008654,
0.00006026,
7144217252.9,
554239.7346328925
],
"type": "ticker.ftbtc",
"seq": 2995173
}
}
我可以将buf
or 响应转换为 key => value 样式Vec
或数组吗?