Module tenlib.transform.json
Functions
def encode(data, indent: Optional[int] = None, **kwargs) ‑> str
-
Wrapper for
json.dumps()
. def decode(data: str, **kwargs) ‑> Any
-
Wrapper for
json.loads()
. def read(data: str, **kwargs) ‑> Any
-
Wrapper for
json.loads()
. def write(data, indent: Optional[int] = None, **kwargs) ‑> str
-
Wrapper for
json.dumps()
.
Classes
class JSONDecodeError (msg, doc, pos)
-
Subclass of ValueError with the following additional properties:
msg: The unformatted error message doc: The JSON document being parsed pos: The start index of doc where parsing failed lineno: The line corresponding to pos colno: The column corresponding to pos
Expand source code
class JSONDecodeError(ValueError): """Subclass of ValueError with the following additional properties: msg: The unformatted error message doc: The JSON document being parsed pos: The start index of doc where parsing failed lineno: The line corresponding to pos colno: The column corresponding to pos """ # Note that this exception is used from _json def __init__(self, msg, doc, pos): lineno = doc.count('\n', 0, pos) + 1 colno = pos - doc.rfind('\n', 0, pos) errmsg = '%s: line %d column %d (char %d)' % (msg, lineno, colno, pos) ValueError.__init__(self, errmsg) self.msg = msg self.doc = doc self.pos = pos self.lineno = lineno self.colno = colno def __reduce__(self): return self.__class__, (self.msg, self.doc, self.pos)
Ancestors
- builtins.ValueError
- builtins.Exception
- builtins.BaseException
Subclasses
- requests.exceptions.JSONDecodeError