@library.filter
def tojson(value):
 try:
  result = json.dumps(_recursive_escape(value), cls=DjangoJSONEncoder)
 except Exception:
  return ''
 return jinja2.Markup(result)

@ library . filter def tojson ( value ) : try : result = json . dumps ( _recursive_escape ( value ) , cls = DjangoJSONEncoder ) except Exception : return '' return jinja2 . Markup ( result )
returns the json representation of the value .