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

Method array_value_or_create

src/cst/mod.rs:1255–1264  ·  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 `.array_value_or_set()` to overwrite the root value when it's not an array.

(&self)

Source from the content-addressed store, hash-verified

1253 /// Note: Use `.array_value_or_set()` to overwrite the root value when
1254 /// it's not an array.
1255 pub fn array_value_or_create(&self) -> Option<CstArray> {
1256 match self.value() {
1257 Some(CstNode::Container(CstContainerNode::Array(node))) => Some(node),
1258 Some(_) => None,
1259 None => {
1260 self.set_value(CstInputValue::Array(Vec::new()));
1261 self.array_value()
1262 }
1263 }
1264 }
1265
1266 /// Gets the root value if it's an object or sets the root value as an object.
1267 ///

Callers

nothing calls this directly

Calls 6

ArrayClass · 0.85
valueMethod · 0.80
set_valueMethod · 0.80
array_valueMethod · 0.80
appendMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected