<commit_before>"""Add a template tag to turn python objects into JSON"""
import types
import json

from django import template
from django.utils.safestring import mark_safe

register = template.Library()

@register.filter
def jsonify(obj):
    if isinstance(obj, types.GeneratorType):
        obj = list(obj)
    return mark_safe(json.dumps(obj))

<commit_msg>Remove single quote marks from jsonif<commit_after>"""Add a template tag to turn python objects into JSON"""
import types
import json

from django import template
from django.utils.safestring import mark_safe

register = template.Library()

@register.filter
def jsonify(obj):
    """Turn object into a json instance"""
    if isinstance(obj, types.GeneratorType):
        obj = list(obj)
    return mark_safe(json.dumps(obj).replace("'", "\\'"))

{'fraction_non_alphanumeric': 0.10421836228287841, 'fraction_numerical': 0.0, 'mean_word_length': 4.643356643356643, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2347363', 'n_tokens_mistral': 229, 'n_tokens_neox': 228, 'n_words': 79}