Gets or creates the root value as an object, returns `Some` if successful or `None` if the root value already exists and is not an object. Note: Use `.object_value_or_set()` to overwrite the root value when it's not an object.
(&self)
| 1218 | /// Note: Use `.object_value_or_set()` to overwrite the root value when |
| 1219 | /// it's not an object. |
| 1220 | pub fn object_value_or_create(&self) -> Option<CstObject> { |
| 1221 | match self.value() { |
| 1222 | Some(CstNode::Container(CstContainerNode::Object(node))) => Some(node), |
| 1223 | Some(_) => None, |
| 1224 | None => { |
| 1225 | self.set_value(CstInputValue::Object(Vec::new())); |
| 1226 | self.object_value() |
| 1227 | } |
| 1228 | } |
| 1229 | } |
| 1230 | |
| 1231 | /// Gets the root value if it's an object or sets the root value as an object. |
| 1232 | /// |