relevanceai.utils.json_encoder#

Json Encoder utility

To invoke JSON encoder:

```

from relevanceai import json_encoder

```

Module Contents#

relevanceai.utils.json_encoder.ENCODERS_BY_TYPE#
relevanceai.utils.json_encoder.json_encoder(obj: Any, force_string: bool = False)#

Converts object so it is json serializable If you want to add your own mapping, customize it this way;

Parameters
  • obj (Any) – The object to convert

  • force_string (bool) – If True, forces the object to a string representation. Used mainly for analytics tracking.

Example

YOu can use our JSON encoder easily. >>> documents = [{“value”: np.nan}] >>> client.json_encoder(documents)

If you want to use FastAPI’s json encoder, do this: >>> from fastapi import jsonable_encoder >>> client.json_encoder = jsonable_encoder

class relevanceai.utils.json_encoder.JSONEncoderUtils#
json_encoder(self, obj, force_string: bool = False)#