pub(crate) fn upsert_json_value(
data: &mut Value,
value: &str,
key: &str,
) -> Result<()>
Expand description
Upserts a value into a JSON object based on a dot-separated key.
This function navigates through a mutable serde_json::Value
object using a
path-like key. It creates nested JSON objects if they do not exist along the path.
The value is inserted at the final key in the path.
§Arguments
data
- A mutable reference to theserde_json::Value
to be modified.value
- The string representation of the value to upsert. This string is first parsed as JSON, and if that fails, it’s treated as a plain JSON string.key
- A dot-separated string representing the path to the location for upserting.