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)
| 626 | /// Deeply set a property in the parsed JSON. Marks the file dirty only when |
| 627 | /// the value actually changed (order-aware comparison). |
| 628 | pub 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 |
searching dependent graphs…