Enum serialize::json::Json[src]
pub enum Json {
Number(f64),
String(String),
Boolean(bool),
List(List),
Object(Box<Object>),
Null,
}Represents a json value
Variants
Number | |
String | |
Boolean | |
List | |
Object | |
Null |
Methods
impl Json
fn to_writer(&self, wr: &mut Writer) -> EncodeResult
Encodes a json value into an io::writer. Uses a single line.
fn to_pretty_writer(&self, wr: &mut Writer) -> EncodeResult
Encodes a json value into an io::writer. Pretty-prints in a more readable format.
fn to_pretty_str(&self) -> String
Encodes a json value into a string
fn find<'a>(&'a self, key: &String) -> Option<&'a Json>
If the Json value is an Object, returns the value associated with the provided key. Otherwise, returns None.
fn find_path<'a>(&'a self, keys: &[&String]) -> Option<&'a Json>
Attempts to get a nested Json Object for each key in keys.
If any key is found not to exist, find_path will return None.
Otherwise, it will return the Json value associated with the final key.
fn search<'a>(&'a self, key: &String) -> Option<&'a Json>
If the Json value is an Object, performs a depth-first search until a value associated with the provided key is found. If no value is found or the Json value is not an Object, returns None.
fn is_object<'a>(&'a self) -> bool
Returns true if the Json value is an Object. Returns false otherwise.
fn as_object<'a>(&'a self) -> Option<&'a Object>
If the Json value is an Object, returns the associated TreeMap. Returns None otherwise.
fn is_list<'a>(&'a self) -> bool
Returns true if the Json value is a List. Returns false otherwise.
fn as_list<'a>(&'a self) -> Option<&'a List>
If the Json value is a List, returns the associated vector. Returns None otherwise.
fn is_string<'a>(&'a self) -> bool
Returns true if the Json value is a String. Returns false otherwise.
fn as_string<'a>(&'a self) -> Option<&'a str>
If the Json value is a String, returns the associated str. Returns None otherwise.
fn is_number(&self) -> bool
Returns true if the Json value is a Number. Returns false otherwise.
fn as_number(&self) -> Option<f64>
If the Json value is a Number, returns the associated f64. Returns None otherwise.
fn is_boolean(&self) -> bool
Returns true if the Json value is a Boolean. Returns false otherwise.
fn as_boolean(&self) -> Option<bool>
If the Json value is a Boolean, returns the associated bool. Returns None otherwise.
fn is_null(&self) -> bool
Returns true if the Json value is a Null. Returns false otherwise.
fn as_null(&self) -> Option<()>
If the Json value is a Null, returns (). Returns None otherwise.
Trait Implementations
impl<E: Encoder<S>, S> Encodable<E, S> for Json
impl PartialOrd for Json
Test if two json values are less than one another