{ } Raw JSON

bundles / ipykernel 7.3.0 / ipykernel / jsonutil / json_clean

function

ipykernel.jsonutil:json_clean

source: /ipykernel/jsonutil.py:77

Signature

def json_clean(obj)

Summary

Deprecated, this is a no-op for jupyter-client>=7.

Extended Summary

Clean an object to ensure it's safe to encode in JSON.

Atomic, immutable objects are returned unmodified. Sets and tuples are converted to lists, lists are copied and dicts are also copied.

Note: dicts whose keys could cause collisions upon encoding (such as a dict with both the number 1 and the string '1' as keys) will cause a ValueError to be raised.

Parameters

obj : any python object

Returns

out : object

A version of the input which will not cause an encoding error when encoded as JSON. Note that this function does not encode its inputs, it simply sanitizes it so that there will be no encoding errors later.

Aliases

  • ipykernel.jsonutil.json_clean