Skip to main content
Version: 0.18.21

util.py

great_expectations.core.util.convert_to_json_serializable(data: ToDict) dict
great_expectations.core.util.convert_to_json_serializable(data: ToList) list
great_expectations.core.util.convert_to_json_serializable(data: bool) bool
great_expectations.core.util.convert_to_json_serializable(data: Union[float, numpy.floating]) float
great_expectations.core.util.convert_to_json_serializable(data: Union[int, numpy.integer]) int
great_expectations.core.util.convert_to_json_serializable(data: Union[str, bytes, slice, uuid.UUID, datetime.date, datetime.datetime, numpy.datetime64]) str
great_expectations.core.util.convert_to_json_serializable(data: None) None

Converts an object to one that is JSON-serializable.

WARNING, data may be converted in place.

Parameters

data – an object to convert to a JSON-serializable object

Returns

>>> convert_to_json_serializable(1)1
>>> convert_to_json_serializable("hello")"hello"
>>> convert_to_json_serializable(Polygon([(0,0),(2,0),(2,2),(0,2)]))"POLYGON ((0 0, 2 0, 2 2, 0 2, 0 0))"

Return type

A JSON-serializable object. For example

Raises

TypeError – A non-JSON-serializable field was found.