Skip to main content
Version: 1.0 prerelease

util.py

great_expectations.core.util.convert_to_json_serializable(data: Union[dict, CommentedMap, pandas.core.frame.DataFrame, great_expectations.types.SerializableDictDot, great_expectations.types.base.SerializableDotDict, pydantic.v1.main.BaseModel]) dict
great_expectations.core.util.convert_to_json_serializable(data: Union[list, set, tuple, npt.NDArray, pandas.core.indexes.base.Index, pandas.core.series.Series]) 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.