Skip to main content

substitute_context_json

Function substitute_context_json 

Source
pub fn substitute_context_json(
    template: &str,
    context: &HashMap<String, Value>,
) -> String
Expand description

Substitute {key} placeholders within a serialized JSON string, escaping string values so that the result remains valid JSON.

Use this instead of substitute_context when the template is a serde_json-serialized value that will be deserialized back after substitution. String values are JSON-escaped (double-quotes, backslashes, and control characters). Numbers, bools, and null are substituted as-is.