Menu
×
   ❮   
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE
     ❯   

Template Filter - json_script


Example

Convert an object into a JSON object:

{{ cars|json_script }}
Run Example »

Definition and Usage

The json_script filter converts an object, like a Python tuple, into a JSON object surrounded by <script> tags.


Syntax

{{ value|json_script:id }}

Template filters are defined by using a pipe | character followed by the name of the filter.

Arguments are defined by using a colon : character followed by the argument value(s).


Arguments

Value Description
id Required. A string that will be the id value of the script element.