pub fn set_nested_value(data: &mut Value, path: &str, value: Value)
Expand description
Set nested value in JSON using dot notation path
Creates intermediate objects or arrays as needed when navigating the path. Supports setting values in nested objects and arrays with automatic expansion.
§Path Syntax
"user.name"
- Set object property"items.0"
- Set array element"data.#20"
- Set field named “20” (# prefix removed)"data.##"
- Set field named “#” (first # removed)
§Arguments
data
- The JSON value to modifypath
- Dot-separated path to the target locationvalue
- The value to set at the target location
§Example
use serde_json::json;
use dataflow_rs::engine::utils::set_nested_value;
let mut data = json!({});
set_nested_value(&mut data, "user.name", json!("Alice"));
assert_eq!(data, json!({"user": {"name": "Alice"}}));