<s> from __future__ import unicode_literals <EOL> from django . conf import settings <EOL> from rest_framework . compat import six <EOL> from rest_framework . parsers import BaseParser , ParseError <EOL> from rest_framework . renderers import JSONRenderer <EOL> import ujson <EOL> __author__ = '<STR_LIT>' <EOL> __all__ = [ '<STR_LIT>' , ] <EOL> class UJSONParser ( BaseParser ) : <EOL> """<STR_LIT>""" <EOL> media_type = '<STR_LIT:application/json>' <EOL> renderer_class = JSONRenderer <EOL> def parse ( self , stream , media_type = None , parser_context = None ) : <EOL> """<STR_LIT>""" <EOL> parser_context = parser_context or { } <EOL> encoding = parser_context . get ( '<STR_LIT>' , settings . DEFAULT_CHARSET ) <EOL> try : <EOL> data = stream . read ( ) . decode ( encoding ) <EOL> return ujson . loads ( data ) <EOL> except ValueError as exc : <EOL> raise ParseError ( '<STR_LIT>' % six . text_type ( exc ) ) </s>
