Make a json dump of `data`, that can be used directly in a `<script>` tag. Available as json() inside templates

def _json_safe_dump(self, data):
        """ Make a json dump of `data`, that can be used directly in a `<script>` tag. Available as json() inside templates """
        return json.dumps(data).replace(u'<', u'\\u003c') \
            .replace(u'>', u'\\u003e') \
            .replace(u'&', u'\\u0026') \
            .replace(u"'", u'\\u0027')