'Try to return pretty printed and Pygment highlighted code'

def formatted_json(self, field):

    value = (getattr(self, field) or '')
    try:
        if (not isinstance(value, dict)):
            value = json.loads(value)
        json_value = json.dumps(value, sort_keys=True, indent=2)
        formatter = HtmlFormatter()
        html = highlight(json_value, JsonLexer(), formatter)
        return mark_safe(html)
    except (ValueError, TypeError):
        return value
