filter: convert the variable to JSON output

How to convert variables to JSON output in Anqi CMS template?

jsonThe filter can convert a variable into JSON output.

Usage method

jsonHow to use the filter:

{{ obj|json }}

For example, to convert bannerItem to JSON output, it can be written like this:

{{ item|dump }}
# 显示结果
{
  "logo":"http://127.0.0.1:8001/uploads/202309/14/eba5aa9dc4c45d18.webp",
  "id":1,
  "link":"",
  "alt":"Hello",
  "description":"",
  "type":"default"
}