MCPcopy Create free account
hub / github.com/StackStorm/st2 / default

Function default

st2common/st2common/util/jsonify.py:57–66  ·  view source on GitHub ↗
(obj)

Source from the content-addressed store, hash-verified

55
56
57def default(obj):
58 if hasattr(obj, "__json__") and six.callable(obj.__json__):
59 return obj.__json__()
60 elif isinstance(obj, bytes):
61 # TODO: We should update the code which passes bytes to pass unicode to avoid this
62 # conversion here
63 return obj.decode("utf-8")
64 elif isinstance(obj, bson.ObjectId):
65 return str(obj)
66 raise TypeError
67
68
69def json_encode_native_json(obj, indent=4, sort_keys=False):

Callers

nothing calls this directly

Calls 1

__json__Method · 0.45

Tested by

no test coverage detected