Struct jsonc_parser::ast::Object
source · pub struct Object<'a> {
pub range: Range,
pub properties: Vec<ObjectProp<'a>>,
}
Expand description
Represents an object that may contain properties (ex. {}
, { "prop": 4 }
).
Fields§
§range: Range
§properties: Vec<ObjectProp<'a>>
Implementations§
source§impl<'a> Object<'a>
impl<'a> Object<'a>
sourcepub fn get(&self, name: &str) -> Option<&ObjectProp<'a>>
pub fn get(&self, name: &str) -> Option<&ObjectProp<'a>>
Gets a property value in the object by its name.
sourcepub fn get_string(&self, name: &str) -> Option<&StringLit<'a>>
pub fn get_string(&self, name: &str) -> Option<&StringLit<'a>>
Gets a string property value from the object by name.
Returns None
when not a string or it doesn’t exist.
sourcepub fn get_number(&self, name: &str) -> Option<&NumberLit<'a>>
pub fn get_number(&self, name: &str) -> Option<&NumberLit<'a>>
Gets a number property value from the object by name.
Returns None
when not a number or it doesn’t exist.
sourcepub fn get_boolean(&self, name: &str) -> Option<&BooleanLit>
pub fn get_boolean(&self, name: &str) -> Option<&BooleanLit>
Gets a boolean property value from the object by name.
Returns None
when not a boolean or it doesn’t exist.
sourcepub fn get_object(&self, name: &str) -> Option<&Object<'a>>
pub fn get_object(&self, name: &str) -> Option<&Object<'a>>
Gets an object property value from the object by name.
Returns None
when not an object or it doesn’t exist.
sourcepub fn get_array(&self, name: &str) -> Option<&Array<'a>>
pub fn get_array(&self, name: &str) -> Option<&Array<'a>>
Gets an array property value from the object by name.
Returns None
when not an array or it doesn’t exist.
sourcepub fn take(&mut self, name: &str) -> Option<ObjectProp<'a>>
pub fn take(&mut self, name: &str) -> Option<ObjectProp<'a>>
Takes a value from the object by name.
Returns None
when it doesn’t exist.
sourcepub fn take_string(&mut self, name: &str) -> Option<StringLit<'a>>
pub fn take_string(&mut self, name: &str) -> Option<StringLit<'a>>
Takes a string property value from the object by name.
Returns None
when not a string or it doesn’t exist.
sourcepub fn take_number(&mut self, name: &str) -> Option<NumberLit<'a>>
pub fn take_number(&mut self, name: &str) -> Option<NumberLit<'a>>
Takes a number property value from the object by name.
Returns None
when not a number or it doesn’t exist.
sourcepub fn take_boolean(&mut self, name: &str) -> Option<BooleanLit>
pub fn take_boolean(&mut self, name: &str) -> Option<BooleanLit>
Takes a boolean property value from the object by name.
Returns None
when not a boolean or it doesn’t exist.
sourcepub fn take_object(&mut self, name: &str) -> Option<Object<'a>>
pub fn take_object(&mut self, name: &str) -> Option<Object<'a>>
Takes an object property value from the object by name.
Returns None
when not an object or it doesn’t exist.
sourcepub fn take_array(&mut self, name: &str) -> Option<Array<'a>>
pub fn take_array(&mut self, name: &str) -> Option<Array<'a>>
Takes an array property value from the object by name.
Returns None
when not an array or it doesn’t exist.