pub fn write_json(out: &mut impl Write, msg: &str) -> Result<()>
Writes a JSON message to the output stream.