pub enum JsonValue {
Null,
Boolean(bool),
Number(f64),
String(String),
Array(Vec<JsonValue>),
Object(HashMap<String, JsonValue>),
}Expand description
A JSON value
Variants§
Null
A null value
Boolean(bool)
A boolean value
Number(f64)
A number value, which is a decimal (f64 in Rust)
String(String)
A string value
Array(Vec<JsonValue>)
An array value
Object(HashMap<String, JsonValue>)
An object value
Implementations§
Source§impl JsonValue
impl JsonValue
Sourcepub fn build_object(input: Vec<(String, JsonValue)>) -> Self
pub fn build_object(input: Vec<(String, JsonValue)>) -> Self
Creates an object instance from a list of String,JsonValue (key,value) tuples.
Sourcepub fn get_boolean(&self) -> Option<bool>
pub fn get_boolean(&self) -> Option<bool>
If the value is a boolean, returns Some(that boolean), else None
Sourcepub fn get_number(&self) -> Option<f64>
pub fn get_number(&self) -> Option<f64>
If the value is a number, returns Some(that number), else None
Sourcepub fn get_string(&self) -> Option<String>
pub fn get_string(&self) -> Option<String>
If the value is a string, returns Some(that string), else None. Note that the string is cloned, so the original value is not borrowed
Sourcepub fn get_array(&self) -> Vec<JsonValue>
pub fn get_array(&self) -> Vec<JsonValue>
If the value is a array, returns a clone of that array; else returns an empty array
Sourcepub fn get_object(&self) -> Option<HashMap<String, JsonValue>>
pub fn get_object(&self) -> Option<HashMap<String, JsonValue>>
If the value is an object, returns Some(a clone of that object’s inner string -> JsonValue hashmap); else returns None
Sourcepub fn get_integer(&self) -> Option<u64>
pub fn get_integer(&self) -> Option<u64>
Returns Some(a u64 integer) if the value can be parsed as such; else None
Sourcepub fn get_json_date(&self) -> Option<JsonDate>
pub fn get_json_date(&self) -> Option<JsonDate>
Returns Some(a JsonDate) if the value can be parsed as such; else None. Note
that this only works with String values that approximate the expected format.
(See JsonDate)