pub enum JsonValue {
Null,
Boolean(bool),
Number(f64),
String(String),
Array(Vec<JsonValue>),
Object(HashMap<String, JsonValue>),
}Expand description
Represents a JSON value.
Supports the six JSON data types: null, boolean, number, string, array, and object.
§Examples
use rust_json_parser::JsonValue;
let value = JsonValue::Number(42.0);
assert_eq!(value.as_f64(), Some(42.0));Variants§
Null
Represents a JSON null value.
Boolean(bool)
Represents a JSON boolean (true or false).
Number(f64)
Represents a JSON number stored as an f64.
String(String)
Represents a JSON string.
Array(Vec<JsonValue>)
Represents a JSON array containing other JSON values.
Object(HashMap<String, JsonValue>)
Represents a JSON object containing key-value pairs.
Implementations§
Source§impl JsonValue
impl JsonValue
pub fn is_null(&self) -> bool
pub fn as_str(&self) -> Option<&str>
pub fn as_f64(&self) -> Option<f64>
pub fn as_bool(&self) -> Option<bool>
pub fn as_array(&self) -> Option<&Vec<JsonValue>>
pub fn as_object(&self) -> Option<&HashMap<String, JsonValue>>
pub fn get(&self, key: &str) -> Option<&JsonValue>
pub fn get_index(&self, index: usize) -> Option<&JsonValue>
Trait Implementations§
impl StructuralPartialEq for JsonValue
Auto Trait Implementations§
impl Freeze for JsonValue
impl RefUnwindSafe for JsonValue
impl Send for JsonValue
impl Sync for JsonValue
impl Unpin for JsonValue
impl UnsafeUnpin for JsonValue
impl UnwindSafe for JsonValue
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more