Convert a json_str into a JsonObj

    :param s: a str instance containing a JSON document
    :param kwargs: arguments see: json.load for details
    :return: JsonObj representing the json string
167564
def loads(s: str, **kwargs) -> JsonObj:
    
    if isinstance(s, (bytes, bytearray)):
        s = s.decode(json.detect_encoding(s), 'surrogatepass')
    return json.loads(s, object_hook=lambda pairs: JsonObj(**pairs), **kwargs)
576604
def to_json(self, *args, **kwargs):
        
        return json.dumps(self.to_schema(), *args, **kwargs)
1269196
def _parse_json(s):
    '''
    
    '''
    return json.loads(s, object_hook=lambda pairs: JsonDict(pairs.iteritems()))
7310
def from_json(cls, json_str):
        
        vocab_dict = json.loads(json_str)

        unknown_token = vocab_dict.get('unknown_token')
        vocab = cls(unknown_token=unknown_token)
        vocab._idx_to_token = vocab_dict.get('idx_to_token')
        vocab._token_to_idx = vocab_dict.get('token_to_idx')
        if unknown_token:
            vocab._token_to_idx = DefaultLookupDict(vocab._token_to_idx[unknown_token],
                                                    vocab._token_to_idx)
        vocab._reserved_tokens = vocab_dict.get('reserved_tokens')
        vocab._padding_token = vocab_dict.get('padding_token')
        vocab._bos_token = vocab_dict.get('bos_token')
        vocab._eos_token = vocab_dict.get('eos_token')
        return vocab
446537
def json_obj(self, method, params=None, auth=True):
        """"""
        if params is None:
            params = {}

        obj = {
            'jsonrpc': '2.0',
            'method': method,
            'params': params,
            'auth': self.__auth if auth else None,
            'id': self.id,
        }

        return json.dumps(obj)
676073
def from_json(j):
    
    if isinstance(j, dict):
        return from_dict(j)

    if not (isinstance(j, str) or isinstance(j, unicode)):
        raise TypeError("argument must be of type str")

    return from_dict(json.loads(j))
737477
def from_json(cls, s):
        
        d = json.loads(s)
        return get_dict_handler(d["type"])(d)
329955
def to_json(self, **kwargs: Mapping) -> str:
        
        content = {
            'Header': dict(self.Header),
            'Reads': self.Reads,
            'Settings': dict(self.Settings),
            'Data': [sample.to_json() for sample in self.samples],
            **{title: dict(getattr(self, title)) for title in self._sections},
        }
        return json.dumps(content, **kwargs)
7442
def __obj2json(self, obj):
        
        return json.dumps(obj, indent=self._indent, sort_keys=self._sort_keys)
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)
61034
def dumps(obj, **kwargs) -> str:
    
    return json.dumps(obj, cls=BioCJSONEncoder, **kwargs)
233829
def load_json(filename: str) -> Union[List, Dict]:
    
    try:
        with open(filename, encoding='utf-8') as fdesc:
            return json.loads(fdesc.read())
    except FileNotFoundError:
        # This is not a fatal error
        _LOGGER.debug('JSON file not found: %s', filename)
    except ValueError as error:
        _LOGGER.exception('Could not parse JSON content: %s', filename)
        raise PytradfriError(error)
    except OSError as error:
        _LOGGER.exception('JSON file reading failed: %s', filename)
        raise PytradfriError(error)
    return {}
442836
def response_to_json_dict(response, **kwargs):
    
    if response.encoding is None:
        response.encoding = 'utf-8'
    return json.loads(response.text, **kwargs)
273250
def json_decode(s: str) -> Any:
    
    try:
        return json.JSONDecoder(object_hook=json_class_decoder_hook).decode(s)
    except json.JSONDecodeError:
        log.warning("Failed to decode JSON (returning None): {!r}", s)
        return None
773264
def from_json(cls, json_str):
        """"""
        d = json.loads(json_str)
        return cls.from_dict(d)
182387
def load_json(self):
        
        try:
            self.request.arguments = json.loads(self.request.body)
        except ValueError:
            msg = "Could not decode JSON: %s" % self.request.body
            self.logger.debug(msg)
            self.raise_error(400, msg)
743953
def json_dumps(obj,       # type: Any
               **kwargs   # type: Any
              ):  # type: (...) -> str
    
    if six.PY2:
        kwargs['encoding'] = 'utf-8'
    return json.dumps(convert_to_dict(obj), **kwargs)