json serialization

Type List

type List = ~[Json]

Type Object

type Object = HashMap<~str, Json>

Enum Json

Represents a json value

Variants

Struct Decoder

pub struct Decoder {
    priv stack: ~[Json],
}

A structure to decode JSON to values in rust.

Struct Encoder

pub struct Encoder {
    priv wr: @io::Writer,
}

A structure for implementing serialization to JSON.

Struct Error

pub struct Error {
    /// The line number at which the error occurred
    line: uint,
    /// The column number at which the error occurred
    col: uint,
    /// A message describing the type of the error
    msg: @~str,
}

If an error occurs while parsing some JSON, this is the structure which is returned

Struct Parser

pub struct Parser {
    priv rdr: @io::Reader,
    priv ch: char,
    priv line: uint,
    priv col: uint,
}

Struct PrettyEncoder

pub struct PrettyEncoder {
    priv wr: @io::Writer,
    priv indent: uint,
}

Another encoder for JSON, but prints out human-readable JSON instead of compact data

Implementation of ::std::cmp::Eq for Error

Automatically derived.

Method eq

fn eq(&self, __arg_0: &Error) -> ::bool

Method ne

fn ne(&self, __arg_0: &Error) -> ::bool

Implementation of serialize::Encoder for Encoder

Method emit_nil

fn emit_nil(&mut self)

Method emit_uint

fn emit_uint(&mut self, v: uint)

Method emit_u64

fn emit_u64(&mut self, v: u64)

Method emit_u32

fn emit_u32(&mut self, v: u32)

Method emit_u16

fn emit_u16(&mut self, v: u16)

Method emit_u8

fn emit_u8(&mut self, v: u8)

Method emit_int

fn emit_int(&mut self, v: int)

Method emit_i64

fn emit_i64(&mut self, v: i64)

Method emit_i32

fn emit_i32(&mut self, v: i32)

Method emit_i16

fn emit_i16(&mut self, v: i16)

Method emit_i8

fn emit_i8(&mut self, v: i8)

Method emit_bool

fn emit_bool(&mut self, v: bool)

Method emit_f64

fn emit_f64(&mut self, v: f64)

Method emit_f32

fn emit_f32(&mut self, v: f32)

Method emit_float

fn emit_float(&mut self, v: float)

Method emit_char

fn emit_char(&mut self, v: char)

Method emit_str

fn emit_str(&mut self, v: &str)

Method emit_enum

fn emit_enum(&mut self, _name: &str, f: &fn(&mut Encoder))

Method emit_enum_variant

fn emit_enum_variant(&mut self, name: &str, _id: uint, cnt: uint,
                     f: &fn(&mut Encoder))

Method emit_enum_variant_arg

fn emit_enum_variant_arg(&mut self, idx: uint, f: &fn(&mut Encoder))

Method emit_enum_struct_variant

fn emit_enum_struct_variant(&mut self, name: &str, id: uint, cnt: uint,
                            f: &fn(&mut Encoder))

Method emit_enum_struct_variant_field

fn emit_enum_struct_variant_field(&mut self, _: &str, idx: uint,
                                  f: &fn(&mut Encoder))

Method emit_struct

fn emit_struct(&mut self, _: &str, _: uint, f: &fn(&mut Encoder))

Method emit_struct_field

fn emit_struct_field(&mut self, name: &str, idx: uint, f: &fn(&mut Encoder))

Method emit_tuple

fn emit_tuple(&mut self, len: uint, f: &fn(&mut Encoder))

Method emit_tuple_arg

fn emit_tuple_arg(&mut self, idx: uint, f: &fn(&mut Encoder))

Method emit_tuple_struct

fn emit_tuple_struct(&mut self, _name: &str, len: uint, f: &fn(&mut Encoder))

Method emit_tuple_struct_arg

fn emit_tuple_struct_arg(&mut self, idx: uint, f: &fn(&mut Encoder))

Method emit_option

fn emit_option(&mut self, f: &fn(&mut Encoder))

Method emit_option_none

fn emit_option_none(&mut self)

Method emit_option_some

fn emit_option_some(&mut self, f: &fn(&mut Encoder))

Method emit_seq

fn emit_seq(&mut self, _len: uint, f: &fn(&mut Encoder))

Method emit_seq_elt

fn emit_seq_elt(&mut self, idx: uint, f: &fn(&mut Encoder))

Method emit_map

fn emit_map(&mut self, _len: uint, f: &fn(&mut Encoder))

Method emit_map_elt_key

fn emit_map_elt_key(&mut self, idx: uint, f: &fn(&mut Encoder))

Method emit_map_elt_val

fn emit_map_elt_val(&mut self, _idx: uint, f: &fn(&mut Encoder))

Implementation of serialize::Encoder for PrettyEncoder

Method emit_nil

fn emit_nil(&mut self)

Method emit_uint

fn emit_uint(&mut self, v: uint)

Method emit_u64

fn emit_u64(&mut self, v: u64)

Method emit_u32

fn emit_u32(&mut self, v: u32)

Method emit_u16

fn emit_u16(&mut self, v: u16)

Method emit_u8

fn emit_u8(&mut self, v: u8)

Method emit_int

fn emit_int(&mut self, v: int)

Method emit_i64

fn emit_i64(&mut self, v: i64)

Method emit_i32

fn emit_i32(&mut self, v: i32)

Method emit_i16

fn emit_i16(&mut self, v: i16)

Method emit_i8

fn emit_i8(&mut self, v: i8)

Method emit_bool

fn emit_bool(&mut self, v: bool)

Method emit_f64

fn emit_f64(&mut self, v: f64)

Method emit_f32

fn emit_f32(&mut self, v: f32)

Method emit_float

fn emit_float(&mut self, v: float)

Method emit_char

fn emit_char(&mut self, v: char)

Method emit_str

fn emit_str(&mut self, v: &str)

Method emit_enum

fn emit_enum(&mut self, _name: &str, f: &fn(&mut PrettyEncoder))

Method emit_enum_variant

fn emit_enum_variant(&mut self, name: &str, _: uint, cnt: uint,
                     f: &fn(&mut PrettyEncoder))

Method emit_enum_variant_arg

fn emit_enum_variant_arg(&mut self, idx: uint, f: &fn(&mut PrettyEncoder))

Method emit_enum_struct_variant

fn emit_enum_struct_variant(&mut self, name: &str, id: uint, cnt: uint,
                            f: &fn(&mut PrettyEncoder))

Method emit_enum_struct_variant_field

fn emit_enum_struct_variant_field(&mut self, _: &str, idx: uint,
                                  f: &fn(&mut PrettyEncoder))

Method emit_struct

fn emit_struct(&mut self, _: &str, len: uint, f: &fn(&mut PrettyEncoder))

Method emit_struct_field

fn emit_struct_field(&mut self, name: &str, idx: uint,
                     f: &fn(&mut PrettyEncoder))

Method emit_tuple

fn emit_tuple(&mut self, len: uint, f: &fn(&mut PrettyEncoder))

Method emit_tuple_arg

fn emit_tuple_arg(&mut self, idx: uint, f: &fn(&mut PrettyEncoder))

Method emit_tuple_struct

fn emit_tuple_struct(&mut self, _: &str, len: uint,
                     f: &fn(&mut PrettyEncoder))

Method emit_tuple_struct_arg

fn emit_tuple_struct_arg(&mut self, idx: uint, f: &fn(&mut PrettyEncoder))

Method emit_option

fn emit_option(&mut self, f: &fn(&mut PrettyEncoder))

Method emit_option_none

fn emit_option_none(&mut self)

Method emit_option_some

fn emit_option_some(&mut self, f: &fn(&mut PrettyEncoder))

Method emit_seq

fn emit_seq(&mut self, len: uint, f: &fn(&mut PrettyEncoder))

Method emit_seq_elt

fn emit_seq_elt(&mut self, idx: uint, f: &fn(&mut PrettyEncoder))

Method emit_map

fn emit_map(&mut self, len: uint, f: &fn(&mut PrettyEncoder))

Method emit_map_elt_key

fn emit_map_elt_key(&mut self, idx: uint, f: &fn(&mut PrettyEncoder))

Method emit_map_elt_val

fn emit_map_elt_val(&mut self, _idx: uint, f: &fn(&mut PrettyEncoder))

Implementation of serialize::Encodable<E> for Json where <E: serialize::Encoder>

Method encode

fn encode(&self, e: &mut E)

Implementation for Parser

Method parse

fn parse(&mut self) -> Result<Json, Error>

Implementation of serialize::Decoder for Decoder

Method read_nil

fn read_nil(&mut self)

Method read_u64

fn read_u64(&mut self) -> u64

Method read_u32

fn read_u32(&mut self) -> u32

Method read_u16

fn read_u16(&mut self) -> u16

Method read_u8

fn read_u8(&mut self) -> u8

Method read_uint

fn read_uint(&mut self) -> uint

Method read_i64

fn read_i64(&mut self) -> i64

Method read_i32

fn read_i32(&mut self) -> i32

Method read_i16

fn read_i16(&mut self) -> i16

Method read_i8

fn read_i8(&mut self) -> i8

Method read_int

fn read_int(&mut self) -> int

Method read_bool

fn read_bool(&mut self) -> bool

Method read_f64

fn read_f64(&mut self) -> f64

Method read_f32

fn read_f32(&mut self) -> f32

Method read_float

fn read_float(&mut self) -> float

Method read_char

fn read_char(&mut self) -> char

Method read_str

fn read_str(&mut self) -> ~str

Method read_enum

fn read_enum<T>(&mut self, name: &str, f: &fn(&mut Decoder) -> T) -> T

Method read_enum_variant

fn read_enum_variant<T>(&mut self, names: &[&str],
                        f: &fn(&mut Decoder, uint) -> T) -> T

Method read_enum_variant_arg

fn read_enum_variant_arg<T>(&mut self, idx: uint, f: &fn(&mut Decoder) -> T)
 -> T

Method read_enum_struct_variant

fn read_enum_struct_variant<T>(&mut self, names: &[&str],
                               f: &fn(&mut Decoder, uint) -> T) -> T

Method read_enum_struct_variant_field

fn read_enum_struct_variant_field<T>(&mut self, name: &str, idx: uint,
                                     f: &fn(&mut Decoder) -> T) -> T

Method read_struct

fn read_struct<T>(&mut self, name: &str, len: uint, f: &fn(&mut Decoder) -> T)
 -> T

Method read_struct_field

fn read_struct_field<T>(&mut self, name: &str, idx: uint,
                        f: &fn(&mut Decoder) -> T) -> T

Method read_tuple

fn read_tuple<T>(&mut self, f: &fn(&mut Decoder, uint) -> T) -> T

Method read_tuple_arg

fn read_tuple_arg<T>(&mut self, idx: uint, f: &fn(&mut Decoder) -> T) -> T

Method read_tuple_struct

fn read_tuple_struct<T>(&mut self, name: &str,
                        f: &fn(&mut Decoder, uint) -> T) -> T

Method read_tuple_struct_arg

fn read_tuple_struct_arg<T>(&mut self, idx: uint, f: &fn(&mut Decoder) -> T)
 -> T

Method read_option

fn read_option<T>(&mut self, f: &fn(&mut Decoder, bool) -> T) -> T

Method read_seq

fn read_seq<T>(&mut self, f: &fn(&mut Decoder, uint) -> T) -> T

Method read_seq_elt

fn read_seq_elt<T>(&mut self, idx: uint, f: &fn(&mut Decoder) -> T) -> T

Method read_map

fn read_map<T>(&mut self, f: &fn(&mut Decoder, uint) -> T) -> T

Method read_map_elt_key

fn read_map_elt_key<T>(&mut self, idx: uint, f: &fn(&mut Decoder) -> T) -> T

Method read_map_elt_val

fn read_map_elt_val<T>(&mut self, idx: uint, f: &fn(&mut Decoder) -> T) -> T

Implementation of Eq for Json

Method eq

fn eq(&self, other: &Json) -> bool

Method ne

fn ne(&self, other: &Json) -> bool

Implementation of Ord for Json

Test if two json values are less than one another

Method lt

fn lt(&self, other: &Json) -> bool

Method le

fn le(&self, other: &Json) -> bool

Method ge

fn ge(&self, other: &Json) -> bool

Method gt

fn gt(&self, other: &Json) -> bool

Implementation of ToJson for Json

Method to_json

fn to_json(&self) -> Json

Implementation of ToJson for @Json

Method to_json

fn to_json(&self) -> Json

Implementation of ToJson for int

Method to_json

fn to_json(&self) -> Json

Implementation of ToJson for i8

Method to_json

fn to_json(&self) -> Json

Implementation of ToJson for i16

Method to_json

fn to_json(&self) -> Json

Implementation of ToJson for i32

Method to_json

fn to_json(&self) -> Json

Implementation of ToJson for i64

Method to_json

fn to_json(&self) -> Json

Implementation of ToJson for uint

Method to_json

fn to_json(&self) -> Json

Implementation of ToJson for u8

Method to_json

fn to_json(&self) -> Json

Implementation of ToJson for u16

Method to_json

fn to_json(&self) -> Json

Implementation of ToJson for u32

Method to_json

fn to_json(&self) -> Json

Implementation of ToJson for u64

Method to_json

fn to_json(&self) -> Json

Implementation of ToJson for float

Method to_json

fn to_json(&self) -> Json

Implementation of ToJson for f32

Method to_json

fn to_json(&self) -> Json

Implementation of ToJson for f64

Method to_json

fn to_json(&self) -> Json

Implementation of ToJson for ()

Method to_json

fn to_json(&self) -> Json

Implementation of ToJson for bool

Method to_json

fn to_json(&self) -> Json

Implementation of ToJson for ~str

Method to_json

fn to_json(&self) -> Json

Implementation of ToJson for @~str

Method to_json

fn to_json(&self) -> Json

Implementation of ToJson for (A, B) where <A: ToJson, B: ToJson>

Method to_json

fn to_json(&self) -> Json

Implementation of ToJson for (A, B, C) where <A: ToJson, B: ToJson, C: ToJson>

Method to_json

fn to_json(&self) -> Json

Implementation of ToJson for ~[A] where <A: ToJson>

Method to_json

fn to_json(&self) -> Json

Implementation of ToJson for HashMap<~str, A> where <A: ToJson + Copy>

Method to_json

fn to_json(&self) -> Json

Implementation of ToJson for Option<A> where <A: ToJson>

Method to_json

fn to_json(&self) -> Json

Implementation of to_str::ToStr for Json

Method to_str

fn to_str(&self) -> ~str

Implementation of to_str::ToStr for Error

Method to_str

fn to_str(&self) -> ~str

Function Decoder

fn Decoder(json: Json) -> Decoder

Creates a new decoder instance for decoding the specified JSON value.

Function Encoder

fn Encoder(wr: @io::Writer) -> Encoder

Creates a new JSON encoder whose output will be written to the writer specified.

Function Parser

fn Parser(rdr: @io::Reader) -> Parser

Decode a json value from an io::reader

Function PrettyEncoder

fn PrettyEncoder(wr: @io::Writer) -> PrettyEncoder

Creates a new encoder whose output will be written to the specified writer

Function from_reader

fn from_reader(rdr: @io::Reader) -> Result<Json, Error>

Decodes a json value from an @io::Reader

Function from_str

fn from_str(s: &str) -> Result<Json, Error>

Decodes a json value from a string

Function to_pretty_str

fn to_pretty_str(json: &Json) -> ~str

Encodes a json value into a string

Function to_pretty_writer

fn to_pretty_writer(wr: @io::Writer, json: &Json)

Encodes a json value into a io::writer

Function to_str

fn to_str(json: &Json) -> ~str

Encodes a json value into a string

Function to_writer

fn to_writer(wr: @io::Writer, json: &Json)

Encodes a json value into a io::writer