Struct json::decoder::Decoder [] [src]

pub struct Decoder<I: Iterator> {
    // some fields omitted
}

JSON decoder over char iterators.

Methods

impl<I: Iterator<Item=char>> Decoder<I>
[src]

fn new(c: Config, i: I) -> Decoder<I>

fn default(i: I) -> Decoder<I>

Create decoder with default Config.

fn into_iter(self) -> I

fn decode(&mut self) -> DecodeResult<Json>

fn skip(&mut self) -> DecodeResult<()>

Decode as generic Json but ignore the result.

Semantically this method is equivalent to Decoder::decode but potentially more efficient as it tries to avoid allocating intermediate values.

fn u8(&mut self) -> DecodeResult<u8>

fn u16(&mut self) -> DecodeResult<u16>

fn u32(&mut self) -> DecodeResult<u32>

fn u64(&mut self) -> DecodeResult<u64>

fn usize(&mut self) -> DecodeResult<usize>

fn i8(&mut self) -> DecodeResult<i8>

fn i16(&mut self) -> DecodeResult<i16>

fn i32(&mut self) -> DecodeResult<i32>

fn i64(&mut self) -> DecodeResult<i64>

fn isize(&mut self) -> DecodeResult<isize>

fn f64(&mut self) -> DecodeResult<f64>

fn null(&mut self) -> DecodeResult<()>

fn bool(&mut self) -> DecodeResult<bool>

fn string(&mut self) -> DecodeResult<String>

fn str(&mut self, b: &mut Utf8Buffer, overflow_err: bool) -> DecodeResult<()>

Decode a JSON string into the given Utf8Buffer.

If the actual string does not fit into the provided buffer and overflow_err is true, DecodeError::BufferOverflow is returned immediately. If overflow_err is false we continue decoding the string, but the buffer will only contain as much as fits into it.

fn optional<A, F>(&mut self, f: F) -> DecodeResult<Option<A>> where F: FnMut(&mut Decoder<I>) -> DecodeResult<A>

Decode null (which is mapped to None) or some other JSON value (mapped to Some).

fn array<A, F>(&mut self, f: F) -> DecodeResult<Option<A>> where F: FnMut(&mut Decoder<I>) -> DecodeResult<A>

fn array1<A, F>(&mut self, f: F) -> DecodeResult<A> where F: FnMut(&mut Decoder<I>) -> DecodeResult<A>

Decode non-empty JSON arrays.

fn array_iter<A, F>(&mut self, f: F) -> DecodeResult<ArrayIter<A, I, F>> where F: FnMut(&mut Decoder<I>) -> DecodeResult<A>

Create a JSON array iterator to conveniently decode a homogenous array.

use json::Decoder;
let mut d = Decoder::default("[1,2,3,4]".chars());
let mut v = vec![];
for i in d.array_iter(Decoder::u8).unwrap() {
    v.push(i.unwrap())
}

fn element<A, F>(&mut self, f: F) -> DecodeResult<Element<A>> where F: FnMut(&mut Decoder<I>) -> DecodeResult<A>

Decode a JSON array element.

fn object<A, F>(&mut self, f: F) -> DecodeResult<Option<A>> where F: FnMut(&mut Decoder<I>) -> DecodeResult<A>

fn object1<A, F>(&mut self, f: F) -> DecodeResult<A> where F: FnMut(&mut Decoder<I>) -> DecodeResult<A>

Decode non-empty JSON objects.

fn key(&mut self) -> DecodeResult<String>

Decode a JSON object key.

fn key_str(&mut self, b: &mut Utf8Buffer, overflow_err: bool) -> DecodeResult<()>

Decode a JSON object key into the given buffer.

fn value<A, F>(&mut self, f: F) -> DecodeResult<Element<A>> where F: FnMut(&mut Decoder<I>) -> DecodeResult<A>

Decode a JSON object value.