is any plan add json_pretty method ?
baoyachi opened this issue · comments
baoyachi commented
json
let json = Request::post(url)
.header("Content-Type", "application/json")
.timeout(Duration::from_secs(timeout))
.body(body)?
.send()?
.json::<serde_json::Value>()?;
Serialize the given data structure as a pretty-printed String of JSON.
like this:
let json = Request::post(url)
.header("Content-Type", "application/json")
.timeout(Duration::from_secs(timeout))
.body(body)?
.send()?
.json_pretty:<serde_json::Value>()?;
Stephen M. Coakley commented
I'm not sure I understand what is being proposed here. In this example, the json
method is de-serializing the response body from the server into the desired type, so a json_pretty
here wouldn't make sense since one method can de-serialize both pretty and compact JSON equivalently.
Isahc doesn't provide any convenience methods right now for serializing the request body, but you can probably use to_vec_pretty
from serde_json to do that.