我正在使用 reqwest 查询 Google API:
let request_url = format!(
"https://maps.googleapis.com/maps/api/place/findplacefromtext/json?input=*\
&inputtype=textquery\
&fields=formatted_address,name,place_id,types\
&locationbias=circle:50@{},{}\
&key=my-secret-key",
lat, lng
);
let mut response = reqwest::get(&request_url).expect("pffff");
let gr: GoogleResponse = response.json::<GoogleResponse>().expect("geeez");
GoogleResponse
结构定义为
#[derive(Debug, Serialize, Deserialize)]
pub struct DebugLog {
pub line: Vec<String>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct Candidate {
pub formatted_address: String,
pub name: String,
pub place_id: String,
pub types: Vec<String>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct GoogleResponse {
pub candidates: Vec<Candidate>,
pub debug_log: DebugLog,
pub status: String,
}
这一切都编译好了,我可以提出请求,但是我在String
字段中得到的结果包含原始的"
. 应该是这样吗?
例如,当打印我得到的格式化地址之一时:
"result": "\"Street blabh blahab blahb\"",
当我真的想要
"result": "Street blabh blahab blahb",
我做错了什么还是这是预期的行为?