method Reply.json
A body that is already JSON text.
Example:
use std.http { Reply }
fn main() io {
let r = Reply.json("{{\"id\":1,\"name\":\"tea\"}}")
print("{r.headers[0].value} {Utf8.decode(r.body)!}")
}Вывод
application/json {"id":1,"name":"tea"}pub(api) static fn json(body: str, status: i64 = 200) -> ReplyС версии. 1.0.0-beta
Параметры
| Имя | Тип |
|---|---|
body | str |
status | i64 = 200 |
Возвращает
Эффекты
не объявлены (чистая, пока тело не говорит иное)
Определено в: std/http/http.oxl:2710