OxL Reference

method Reply.json

A body that is already JSON text.

Example:

oxl✓ checked in CI
use std.http { Reply }

fn main() io {
  let r = Reply.json("{{\"id\":1,\"name\":\"tea\"}}")
  print("{r.headers[0].value} {Utf8.decode(r.body)!}")
}
Output
application/json {"id":1,"name":"tea"}
pub(api) static fn json(body: str, status: i64 = 200) -> Reply

Since. 1.0.0-beta

Parameters

NameType
bodystr
statusi64 = 200

Returns

Reply

Effects

none declared (pure unless the body says otherwise)

Defined in: std/http/http.oxl:2710

See also