Use tojson filter in templates.