Struct Deserializer
pub struct Deserializer<R> { /* private fields */ }
A structure that deserializes JSON into Rust values.
Implementations
impl<'a> Deserializer<SliceRead<'a>>
fn from_slice(bytes: &'a [u8]) -> SelfCreates a JSON deserializer from a
&[u8].
impl<'a> Deserializer<StrRead<'a>>
fn from_str(s: &'a str) -> SelfCreates a JSON deserializer from a
&str.
impl<'de, R> Deserializer<R>
where
R: Read<'de>,
fn new(read: R) -> SelfCreate a JSON deserializer from one of the possible serde_json input sources.
When reading from a source against which short reads are not efficient, such as a
File, you will want to apply your own buffering because serde_json will not buffer the input. Seestd::io::BufReader.Typically it is more convenient to use one of these methods instead:
- Deserializer::from_str
- Deserializer::from_slice
- Deserializer::from_reader
impl<'de, R: Read<'de>> Deserializer<R>
fn end(&mut self) -> Result<()>The
Deserializer::endmethod should be called after a value has been fully deserialized. This allows theDeserializerto validate that the input stream is at the end or that it only has trailing whitespace.fn into_iter<T>(self) -> StreamDeserializer<'de, R, T> where T: Deserialize<'de>,Turn a JSON deserializer into an iterator over values of type T.
impl<R> Deserializer<IoRead<R>>
where
R: Read,
fn from_reader(reader: R) -> SelfCreates a JSON deserializer from an
io::Read.Reader-based deserializers do not support deserializing borrowed types like
&str, since thestd::io::Readtrait has no non-copying methods -- everything it does involves copying bytes out of the data source.