Module json::encoder [] [src]

JSON (RFC 7159) encoder.

Usage example

use json::Encoder;
use std::io::Cursor;

let mut e = Encoder::new(Cursor::new(Vec::new()));
let r = e.object().and_then(|()| {
    e.key("key1")?; e.array()?;
        for i in 0 .. 10 {
            e.bool(i % 2 == 0)?
        }
    e.end()?;
    e.key("key2")?; e.string("\"hello world\"")?;
    e.key("key3")?; e.object()?;
        e.key("inner1")?; e.bool(true)?;
        e.key("inner2")?; e.array()?;
            e.string("\u{2764}\u{fe0f}")?;
            e.string("again")?;
            e.bool(false)?;
            e.usize(1024)?;
            e.u8(90)?;
            e.f64(1.23442e-9)?;
            e.null()?;
        e.end()?;
    e.end()?;
e.end()});
assert!(r.is_ok())

Structs

Encoder

JSON encoder over any Write-type.

Enums

EncodeError

Traits

ToJson

Type Definitions

EncodeResult