Enum purp_value::types::object::Object
source · pub enum Object {
BTreeMap(BTreeMap<String, Value>),
HashMap(HashMap<String, Value>),
}Expand description
An enum representing a JSON object as a BTreeMap or a HashMap.
Variants§
Implementations§
source§impl Object
impl Object
sourcepub fn get(&self, key: &str) -> Option<&Value>
pub fn get(&self, key: &str) -> Option<&Value>
Returns a reference to the value associated with the specified key, or None if the key is not present.
sourcepub fn insert(&mut self, key: String, value: Value) -> Option<Value>
pub fn insert(&mut self, key: String, value: Value) -> Option<Value>
Inserts a key-value pair into the object. If the key already exists, returns the previous value associated with the key.
sourcepub fn remove(&mut self, key: &str) -> Option<Value>
pub fn remove(&mut self, key: &str) -> Option<Value>
Removes a key-value pair from the object and returns the associated value. If the key is not present, returns None.
sourcepub fn contains_key(&self, key: &str) -> bool
pub fn contains_key(&self, key: &str) -> bool
Returns true if the object contains a value for the specified key, otherwise false.
sourcepub fn keys(&self) -> Vec<&String>
pub fn keys(&self) -> Vec<&String>
Returns a Vec of references to the keys in the object, in the order they were inserted.
sourcepub fn values(&self) -> Vec<&Value>
pub fn values(&self) -> Vec<&Value>
Returns a Vec of references to the values in the object, in the order they were inserted.