Return an instance of the appropriate class from the json_dict.
424799
def from_api_response(cls, reddit_session, json_dict):
        """"""
        # The WikiPage response does not contain the necessary information
        # in the JSON response to determine the name of the page nor the
        # subreddit it belongs to. Thus we must extract this information
        # from the request URL.
        # pylint: disable=W0212
        parts = reddit_session._request_url.split('/', 6)
        # pylint: enable=W0212
        subreddit = parts[4]
        page = parts[6].split('.', 1)[0]
        return cls(reddit_session, subreddit, page, json_dict=json_dict)
207627
def _to_dict(self):
        """"""
        _dict = {}
        if hasattr(self, 'text') and self.text is not None:
            _dict['text'] = self.text
        if hasattr(self, 'top_class') and self.top_class is not None:
            _dict['top_class'] = self.top_class
        if hasattr(self, 'classes') and self.classes is not None:
            _dict['classes'] = [x._to_dict() for x in self.classes]
        return _dict
867970
def from_json(cls, json):
        """"""
        obj = cls(name=json['name'],
                  code=json['code'],
                  numeric_code=json['numeric_code'],
                  symbol=json['symbol'],
                  exponent=json['exponent'],
                  entities=json['entities'],
                  withdrawal_date=json['withdrawal_date'],
                  subunits=json['subunits'])
        return obj
1010112
def parameter_from_json(dictionary, bundle=None):
    
    if isinstance(dictionary, str):
        dictionary = json.loads(dictionary, object_pairs_hook=parse_json)

    classname = dictionary.pop('Class')

    if classname not in _parameter_class_that_require_bundle:
        bundle = None

    # now let's do some dirty magic and get the actual classitself
    # from THIS module.  __name__ is a string to lookup this module
    # from the sys.modules dictionary
    cls = getattr(sys.modules[__name__], classname)

    return cls._from_json(bundle, **dictionary)
750362
def from_json(cls, key):
        
        obj = cls()
        try:
            jkey = json_decode(key)
        except Exception as e:  # pylint: disable=broad-except
            raise InvalidJWKValue(e)
        obj.import_key(**jkey)
        return obj
749228
def from_json(cls, json_dump):
        
        context = cls()
        if json_dump is None:
            return None
        ctxt = json.loads(json_dump)
        for k in ctxt:
            context[k] = ctxt[k]
        return context
157562
def loader_cls(self):
        """"""
        cls = self.app.config['JSONSCHEMAS_LOADER_CLS']
        if isinstance(cls, six.string_types):
            return import_string(cls)
        return cls
1208573
def from_jsonld(cls, data, __reference__=None, __source__=None):
        """"""
        if isinstance(data, cls):
            return data

        if not isinstance(data, dict):
            raise ValueError(data)

        if '@type' in data:
            type_ = tuple(sorted(data['@type']))
            if type_ in cls.__type_registry__ and getattr(
                cls, '_jsonld_type', None
            ) != type_:
                new_cls = cls.__type_registry__[type_]
                if cls != new_cls:
                    return new_cls.from_jsonld(data)

        if cls._jsonld_translate:
            data = ld.compact(data, {'@context': cls._jsonld_translate})
            data.pop('@context', None)

        data.setdefault('@context', cls._jsonld_context)

        if data['@context'] != cls._jsonld_context:
            compacted = ld.compact(data, {'@context': cls._jsonld_context})
        else:
            compacted = data

        # assert compacted['@type'] == cls._jsonld_type, '@type must be equal'
        # TODO update self(not cls)._jsonld_context with data['@context']
        fields = cls._jsonld_fields

        if __reference__:
            with with_reference(__reference__):
                self = cls(
                    **{
                        k.lstrip('_'): v
                        for k, v in compacted.items() if k in fields
                    }
                )
        else:
            self = cls(
                **{
                    k.lstrip('_'): v
                    for k, v in compacted.items() if k in fields
                }
            )
        if __source__:
            setattr(self, '__source__', __source__)
        return self
678745
def from_json(cls, json_obj):
        
        if isinstance(json_obj, str):
            json_obj = json.loads(json_obj)

        time = None
        value = None

        if cls.TIME_FIELD_NAME in json_obj:
            time = json_obj[cls.TIME_FIELD_NAME]
        else:
            raise InvalidMetricError("{field} must be present!".format(
                field=cls.TIME_FIELD_NAME))

        if cls.VALUE_FIELD_NAME in json_obj:
            value = json_obj[cls.VALUE_FIELD_NAME]

        return cls(time, value)
2548
def get(self, key):
        
        return self._object_class(json.loads(self._db[key]))
16282
def from_dict(cls, d):
        
        conf = {}
        for k in d["config"]:
            v = d["config"][k]
            if isinstance(v, dict):
                conf[str(k)] = get_dict_handler(d["config"]["type"])(v)
            else:
                conf[str(k)] = v
        return get_class(str(d["class"]))(config=conf)
571170
def _from_dict(cls, _dict):
        """"""
        args = {}
        if 'classifiers' in _dict:
            args['classifiers'] = [
                Classifier._from_dict(x) for x in (_dict.get('classifiers'))
            ]
        else:
            raise ValueError(
                'Required property \'classifiers\' not present in ClassifierList JSON'
            )
        return cls(**args)
444350
def json_loads(cls, s, **kwargs):
        
        if 'cls' not in kwargs:
            kwargs['cls'] = cls.json_decoder
        return json.loads(s, **kwargs)
10436
def to_dict(obj):
    
    d = _to_json_type(obj)
    if isinstance(d, dict):
        return scrub_dict(d)
    else:
        raise ValueError("The value provided must be an object.")
1307746
def from_dict(cls, d):
        """"""
        return cls(
            d['type'], tuple(d['parents']), list(d['properties'].items())
        )
335085
def _from_dict(cls, _dict):
        """"""
        args = {}
        if 'fields' in _dict:
            args['fields'] = [
                Field._from_dict(x) for x in (_dict.get('fields'))
            ]
        return cls(**args)
511866
def _dict_to_obj(self, d):
    """"""
    if JsonEncoder.TYPE_ID not in d:
      return d

    type_name = d.pop(JsonEncoder.TYPE_ID)
    if type_name in _TYPE_NAME_TO_DECODER:
      decoder = _TYPE_NAME_TO_DECODER[type_name]
      return decoder(d)
    else:
      raise TypeError("Invalid type %s.", type_name)