json_script
Output value JSON-encoded, wrapped in a < script type="application/json" > tag (with an optional id).
def json_script(
value: any,
element_id: string = None
) - > string
Output value JSON-encoded, wrapped in a < script type="application/json" > tag (with an optional id).
Parameters
| Name | Type | Description |
|---|---|---|
| value | any | The Python object to be serialized into JSON format. |
| element_id | string = None | An optional HTML ID attribute to assign to the generated script tag for easy selection via JavaScript. |
Returns
| Type | Description |
|---|---|
string | A string containing the JSON-encoded data wrapped in a script tag, marked as safe for HTML output. |