MCPcopy Create free account
hub / github.com/dprint/jsonc-parser / object_value_or_create

Method object_value_or_create

src/cst/mod.rs:1220–1229  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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 ///

Calls 6

ObjectClass · 0.85
valueMethod · 0.80
set_valueMethod · 0.80
object_valueMethod · 0.80
appendMethod · 0.80
getMethod · 0.45