MCPcopy Create free account
hub / github.com/simplejson/simplejson / _stringify_key

Function _stringify_key

simplejson/encoder.py:580–605  ·  view source on GitHub ↗
(key)

Source from the content-addressed store, hash-verified

578 del markers[markerid]
579
580 def _stringify_key(key):
581 if isinstance(key, string_types): # pragma: no cover
582 pass
583 elif _PY3 and isinstance(key, bytes) and _encoding is not None:
584 key = str(key, _encoding)
585 elif isinstance(key, float):
586 key = _floatstr(key)
587 elif key is True:
588 key = 'true'
589 elif key is False:
590 key = 'false'
591 elif key is None:
592 key = 'null'
593 elif isinstance(key, integer_types):
594 if type(key) not in integer_types:
595 # See #118, do not trust custom str/repr
596 key = int(key)
597 key = str(key)
598 elif _use_decimal and isinstance(key, Decimal):
599 key = str(key)
600 elif _skipkeys:
601 key = None
602 else:
603 raise TypeError('keys must be str, int, float, bool or None, '
604 'not %s' % key.__class__.__name__)
605 return key
606
607 def _iterencode_dict(dct, _current_indent_level):
608 if not dct:

Callers 1

_iterencode_dictFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…