Insert `value` into `map` under `key`. If the key is already present and the schema-declared shape is an array, append the new value to a sibling array rather than overwriting — this is how repeated `--keywords foo --keywords bar` accumulates. Called after [`coerce_value`], so the value is already the right JSON type (or a string we'll wrap in an array on first sight of a second occurrence).
(map: &mut Map<String, Value>, key: &str, value: Value)
| 646 | /// Called after [`coerce_value`], so the value is already the right JSON type |
| 647 | /// (or a string we'll wrap in an array on first sight of a second occurrence). |
| 648 | fn merge_value(map: &mut Map<String, Value>, key: &str, value: Value) { |
| 649 | if let Some(existing) = map.get_mut(key) { |
| 650 | match existing { |
| 651 | Value::Array(arr) => arr.push(value), |
| 652 | _ => { |
| 653 | let prev = std::mem::replace(existing, Value::Null); |
| 654 | *existing = Value::Array(vec![prev, value]); |
| 655 | } |
| 656 | } |
| 657 | } else { |
| 658 | map.insert(key.to_string(), value); |
| 659 | } |
| 660 | } |
| 661 | |
| 662 | /// Promote any `array<string>` properties from a single string into a real |
| 663 | /// array: split on commas if the user passed `--keywords foo,bar`, or wrap a |
no test coverage detected