Skip to main content

json_script

Function json_script 

Source
pub fn json_script<T>(
    id: &str,
    value: &T,
) -> Result<PreEscaped<String>, SlabError>
where T: Serialize,
Expand description

Serialize value as JSON safely embedded inside <script type="application/json" id="...">.

Escapes <, >, &, U+2028, and U+2029 so untrusted strings cannot break out of the <script> tag or smuggle executable HTML/JavaScript.