Set a key on a parent object. Uses direct Map access so keys may contain `/` (eg. scoped npm packages like `@scope/name`). Marks dirty only when the value actually changed.
(file: &mut File<JsonValue>, parent_pointer: &str, key: &str, next_value: JsonValue)
| 643 | /// `/` (eg. scoped npm packages like `@scope/name`). Marks dirty only when |
| 644 | /// the value actually changed. |
| 645 | pub fn set_nested_prop(file: &mut File<JsonValue>, parent_pointer: &str, key: &str, next_value: JsonValue) { |
| 646 | if let Some(JsonValue::Object(obj)) = file.contents.pointer_mut(parent_pointer) { |
| 647 | let is_changed = obj.get(key).is_none_or(|value| json_values_differ(value, &next_value)); |
| 648 | if is_changed { |
| 649 | obj.insert(key.to_string(), next_value); |
| 650 | file.dirty = true; |
| 651 | } |
| 652 | } |
| 653 | } |
| 654 | |
| 655 | /// Remove a key from a parent object. Marks dirty only when the key existed. |
| 656 | pub fn remove_prop(file: &mut File<JsonValue>, parent_pointer: &str, key: &str) { |
searching dependent graphs…