Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Bower components Debian packages RPM packages NuGet packages

hemamaps / coreapi   python

Repository URL to install this package:

Version: 1.32.0 

/ codecs / jsondata.py

# coding: utf-8
from coreapi.codecs.base import BaseCodec
from coreapi.exceptions import ParseError
import collections
import json


class JSONCodec(BaseCodec):
    media_type = 'application/json'
    supports = ['data']

    def load(self, bytes, base_url=None):
        """
        Return raw JSON data.
        """
        try:
            return json.loads(bytes.decode('utf-8'), object_pairs_hook=collections.OrderedDict)
        except ValueError as exc:
            raise ParseError('Malformed JSON. %s' % exc)