Skip to main content

set_nested_value

Function set_nested_value 

Source
pub fn set_nested_value(
    data: &mut OwnedDataValue,
    path: &str,
    value: OwnedDataValue,
)
Expand description

Set the value at path, creating intermediate containers as needed.

Mirrors the original serde_json::Value flavour:

  • intermediate containers are created on demand; the next path part determines whether to create an Object (string key) or Array (numeric index);
  • arrays grow with OwnedDataValue::Null padding when an index past the current end is assigned;
  • #-prefix escape applies inside object contexts only;
  • silently no-ops when traversing through a non-container in a non- terminal hop or when an array path part isn’t a valid usize.