MCPcopy Create free account
hub / github.com/JamieMason/syncpack / set_prop

Function set_prop

src/disk.rs:628–640  ·  view source on GitHub ↗

Deeply set a property in the parsed JSON. Marks the file dirty only when the value actually changed (order-aware comparison).

(file: &mut File<JsonValue>, pointer: &str, next_value: JsonValue)

Source from the content-addressed store, hash-verified

626/// Deeply set a property in the parsed JSON. Marks the file dirty only when
627/// the value actually changed (order-aware comparison).
628pub fn set_prop(file: &mut File<JsonValue>, pointer: &str, next_value: JsonValue) {
629 if pointer == "/" {
630 if json_values_differ(&file.contents, &next_value) {
631 file.contents = next_value;
632 file.dirty = true;
633 }
634 } else if let Some(value) = file.contents.pointer_mut(pointer)
635 && json_values_differ(value, &next_value)
636 {
637 *value = next_value;
638 file.dirty = true;
639 }
640}
641
642/// Set a key on a parent object. Uses direct Map access so keys may contain
643/// `/` (eg. scoped npm packages like `@scope/name`). Marks dirty only when

Calls 1

json_values_differFunction · 0.85

Used in the wild real call sites across dependent graphs

searching dependent graphs…