from django import template
from django.utils.safestring import mark_safe
register = template.Library()

@register.filter
def as_json(data):
    return mark_safe(simplejson.dumps(data))
passing unicode strings from django to javascript