import ujson
from rest_framework import VERSION, exceptions, serializers, status
from rest_framework.compat import (
    INDENT_SEPARATORS, LONG_SEPARATORS, SHORT_SEPARATORS, coreapi,
    template_render
)
from django.conf import settings
from rest_framework.renderers import JSONRenderer
from collections import defaultdict


class USJONRenderer(JSONRenderer):
    ensure_ascii = False
    double_precision = 3
    escape_forward_slashes = False

    def render(self, data, accepted_media_type=None, renderer_context=None):
        """
        Render `data` into JSON, returning a bytestring.
        """
        if data is None:
            return bytes()
        renderer_context = renderer_context or {}
        indent = self.get_indent(accepted_media_type, renderer_context)

        if indent is None:
            separators = SHORT_SEPARATORS if self.compact else LONG_SEPARATORS
        else:
            separators = INDENT_SEPARATORS

        ret = ujson.dumps(data, ensure_ascii=self.ensure_ascii,
                          double_precision=self.double_precision, escape_forward_slashes=self.escape_forward_slashes)
        # On python 2.x json.dumps() returns bytestrings if ensure_ascii=True,
        # but if ensure_ascii=False, the return type is underspecified,
        # and may (or may not) be unicode.
        # On python 3.x json.dumps() returns unicode strings.
        if isinstance(ret, six.text_type):
            # We always fully escape \u2028 and \u2029 to ensure we output JSON
            # that is a strict javascript subset. If bytes were returned
            # by json.dumps() then we don't have these characters in any case.
            # See: http://timelessrepo.com/json-isnt-a-javascript-subset
            ret = ret.replace('\u2028', '\\u2028').replace('\u2029', '\\u2029')
            return bytes(ret.encode('utf-8'))
        return ret

9de964c6c96173445b112d07b31549a039a16318
<mask token>


class USJONRenderer(JSONRenderer):
    <mask token>
    <mask token>
    <mask token>
    <mask token>

<mask token>


class USJONRenderer(JSONRenderer):
    <mask token>
    <mask token>
    <mask token>

    def render(self, data, accepted_media_type=None, renderer_context=None):
        """
        Render `data` into JSON, returning a bytestring.
        """
        if data is None:
            return bytes()
        renderer_context = renderer_context or {}
        indent = self.get_indent(accepted_media_type, renderer_context)
        if indent is None:
            separators = SHORT_SEPARATORS if self.compact else LONG_SEPARATORS
        else:
            separators = INDENT_SEPARATORS
        ret = ujson.dumps(data, ensure_ascii=self.ensure_ascii,
            double_precision=self.double_precision, escape_forward_slashes=
            self.escape_forward_slashes)
        if isinstance(ret, six.text_type):
            ret = ret.replace('\u2028', '\\u2028').replace('\u2029', '\\u2029')
            return bytes(ret.encode('utf-8'))
        return ret

<mask token>


class USJONRenderer(JSONRenderer):
    ensure_ascii = False
    double_precision = 3
    escape_forward_slashes = False

    def render(self, data, accepted_media_type=None, renderer_context=None):
        """
        Render `data` into JSON, returning a bytestring.
        """
        if data is None:
            return bytes()
        renderer_context = renderer_context or {}
        indent = self.get_indent(accepted_media_type, renderer_context)
        if indent is None:
            separators = SHORT_SEPARATORS if self.compact else LONG_SEPARATORS
        else:
            separators = INDENT_SEPARATORS
        ret = ujson.dumps(data, ensure_ascii=self.ensure_ascii,
            double_precision=self.double_precision, escape_forward_slashes=
            self.escape_forward_slashes)
        if isinstance(ret, six.text_type):
            ret = ret.replace('\u2028', '\\u2028').replace('\u2029', '\\u2029')
            return bytes(ret.encode('utf-8'))
        return ret

import ujson
from rest_framework import VERSION, exceptions, serializers, status
from rest_framework.compat import INDENT_SEPARATORS, LONG_SEPARATORS, SHORT_SEPARATORS, coreapi, template_render
from django.conf import settings
from rest_framework.renderers import JSONRenderer
from collections import defaultdict


class USJONRenderer(JSONRenderer):
    ensure_ascii = False
    double_precision = 3
    escape_forward_slashes = False

    def render(self, data, accepted_media_type=None, renderer_context=None):
        """
        Render `data` into JSON, returning a bytestring.
        """
        if data is None:
            return bytes()
        renderer_context = renderer_context or {}
        indent = self.get_indent(accepted_media_type, renderer_context)
        if indent is None:
            separators = SHORT_SEPARATORS if self.compact else LONG_SEPARATORS
        else:
            separators = INDENT_SEPARATORS
        ret = ujson.dumps(data, ensure_ascii=self.ensure_ascii,
            double_precision=self.double_precision, escape_forward_slashes=
            self.escape_forward_slashes)
        if isinstance(ret, six.text_type):
            ret = ret.replace('\u2028', '\\u2028').replace('\u2029', '\\u2029')
            return bytes(ret.encode('utf-8'))
        return ret

import ujson
from rest_framework import VERSION, exceptions, serializers, status
from rest_framework.compat import (
    INDENT_SEPARATORS, LONG_SEPARATORS, SHORT_SEPARATORS, coreapi,
    template_render
)
from django.conf import settings
from rest_framework.renderers import JSONRenderer
from collections import defaultdict


class USJONRenderer(JSONRenderer):
    ensure_ascii = False
    double_precision = 3
    escape_forward_slashes = False

    def render(self, data, accepted_media_type=None, renderer_context=None):
        """
        Render `data` into JSON, returning a bytestring.
        """
        if data is None:
            return bytes()
        renderer_context = renderer_context or {}
        indent = self.get_indent(accepted_media_type, renderer_context)

        if indent is None:
            separators = SHORT_SEPARATORS if self.compact else LONG_SEPARATORS
        else:
            separators = INDENT_SEPARATORS

        ret = ujson.dumps(data, ensure_ascii=self.ensure_ascii,
                          double_precision=self.double_precision, escape_forward_slashes=self.escape_forward_slashes)
        # On python 2.x json.dumps() returns bytestrings if ensure_ascii=True,
        # but if ensure_ascii=False, the return type is underspecified,
        # and may (or may not) be unicode.
        # On python 3.x json.dumps() returns unicode strings.
        if isinstance(ret, six.text_type):
            # We always fully escape \u2028 and \u2029 to ensure we output JSON
            # that is a strict javascript subset. If bytes were returned
            # by json.dumps() then we don't have these characters in any case.
            # See: http://timelessrepo.com/json-isnt-a-javascript-subset
            ret = ret.replace('\u2028', '\\u2028').replace('\u2029', '\\u2029')
            return bytes(ret.encode('utf-8'))
        return ret
