MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / collect_keys

Function collect_keys

atomic-canonical/src/context.rs:29–40  ·  view source on GitHub ↗

Collect every object key appearing anywhere in `value`.

(value: &Value, out: &mut BTreeSet<String>)

Source from the content-addressed store, hash-verified

27
28/// Collect every object key appearing anywhere in `value`.
29pub fn collect_keys(value: &Value, out: &mut BTreeSet<String>) {
30 match value {
31 Value::Object(map) => {
32 for (k, v) in map {
33 out.insert(k.clone());
34 collect_keys(v, out);
35 }
36 }
37 Value::Array(items) => items.iter().for_each(|v| collect_keys(v, out)),
38 _ => {}
39 }
40}
41
42/// The keys in `value` that the context must define: bare terms only —
43/// JSON-LD keywords (`@id`, `@type`, …) need no term, and CURIEs (`prov:Activity`)

Callers 1

undefined_termsFunction · 0.85

Calls 3

insertMethod · 0.45
cloneMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected