sanitizejson(obj, verbose=True, die=False, tostring=False, **kwargs)[source]

This is the main conversion function for Python data-structures into JSON-compatible data structures (note: sanitizejson/jsonify are identical).

  • obj (any) – almost any kind of data structure that is a combination of list, numpy.ndarray, odicts, etc.

  • verbose (bool) – level of detail to print

  • die (bool) – whether or not to raise an exception if conversion failed (otherwise, return a string)

  • tostring (bool) – whether to return a string representation of the sanitized object instead of the object itself

  • kwargs (dict) – passed to json.dumps() if tostring=True


the converted object that should be JSON compatible, or its representation as a string if tostring=True

Return type

object (any or str)

Version: 2020apr11