Return the Python representation of ``s`` (a ``str`` or ``unicode``
        instance containing a JSON document)
346841
def decode(self, s, _w=WHITESPACE.match):
        
        obj, end = self.raw_decode(s, idx=_w(s, 0).end())
        end = _w(s, end).end()
        if end != len(s):
            raise JSONDecodeError("Extra data", s, end, len(s))
        return 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))
958030
def _bson_to_dict(data, opts):
    """"""
    try:
        if _raw_document_class(opts.document_class):
            return opts.document_class(data, opts)
        _, end = _get_object_size(data, 0, len(data))
        return _elements_to_dict(data, 4, end, opts)
    except InvalidBSON:
        raise
    except Exception:
        # Change exception type to InvalidBSON but preserve traceback.
        _, exc_value, exc_tb = sys.exc_info()
        reraise(InvalidBSON, exc_value, exc_tb)
1307202
def json_pretty_print(s):
    ''''''
    s = json.loads(s)
    return json.dumps(s,
                      sort_keys=True,
                      indent=4,
                      separators=(',', ': '))
108037
def json2pattern(s):
    
    # make valid JSON by wrapping field names in quotes
    s, _ = re.subn(r'([{,])\s*([^,{\s\'"]+)\s*:', ' \\1 "\\2" : ', s)
    # handle shell values that are not valid JSON
    s = shell2json(s)
    # convert to 1 where possible, to get rid of things like new Date(...)
    s, n = re.subn(r'([:,\[])\s*([^{}\[\]"]+?)\s*([,}\]])', '\\1 1 \\3', s)
    # now convert to dictionary, converting unicode to ascii
    try:
        doc = json.loads(s, object_hook=_decode_pattern_dict)
        return json.dumps(doc, sort_keys=True, separators=(', ', ': '))
    except ValueError as ex:
        return None
884602
def native_string_to_unicode(s, encoding="ascii", errors="strict"):
    
    if not isinstance(s, str):
        raise TypeError("{} must be type str, not {}".format(s, type(s)))
    if str is unicode:
        # Python 3
        return s
    else:
        # Python 2
        return s.decode(encoding=encoding, errors=errors)
380611
def _parse_repr(self):
         

         repr_ = self.get_value()
         repr_str = '["{}"]'.format(repr_.replace(', ', '", "').replace('(', '", ["').replace(')', '"]')).replace(']"', '"]').replace('""', '"').replace(']"', ']')
         return json.loads(repr_str)
1090032
def to_string(s, encoding='utf-8'):
    
    if six.PY2:
        return s.encode(encoding)
    if isinstance(s, bytes):
        return s.decode(encoding)
    return s
1143963
def json(self):
        

        if six.PY3:
            return json.loads(self.body.decode(self.charset))
        else:
            return json.loads(self.body)
82877
def _json_dumps(self, d):
        
        try:
            return json.dumps(d)
        except UnicodeDecodeError:
            return json.dumps(d, ensure_ascii=False)
833181
def ToJson(self):
        
        jsn = {
            'name': self.name,
            'symbol': self.symbol,
            'decimals': self.decimals,
            'script_hash': self.ScriptHash.To0xString(),
            'contract_address': self.Address
        }
        return jsn
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
1156048
def string(value) -> str:
        
        return system_json.dumps(Json(value).safe_object(), ensure_ascii=False)
305958
def json(self):
        """"""
        attributes = {
            'type': self.type,
            'filename': self.filename,
            'line_number': self.lineno,
            'hashed_secret': self.secret_hash,
        }

        if self.is_secret is not None:
            attributes['is_secret'] = self.is_secret

        return attributes
1088351
def to_str(s, encoding=None, errors='strict'):
    
    encoding = encoding or 'utf-8'

    if is_strlike(s):
        if six.PY2:
            return s.encode(encoding, errors) if isinstance(s, unicode) else s
        else:
            return s.decode(encoding, errors) if isinstance(s, bytes) else s
    else:
        return str(s)
850021
def AsJsonString(self):
        
        return json.dumps(self.AsDict(dt=False), sort_keys=True)
888301
def json_repr(self, minimal=False):
        
        if self.value:
            return [self.field, self.operator, self.value]
        else:
            return [self.field, self.operator]