docs: def jsanitize(obj, strict=False, allow_bson=False):
      """
      This method cleans an input json-like object, either a list or a dict or
      some sequence, nested or otherwise, by converting all non-string
      dictionary keys (such as int and float) to strings, and also recursively
      encodes all objects using Monty's as_dict() protocol.
  
      Args:
          obj: input json-like object.
          strict (bool): This parameters sets the behavior when jsanitize
              encounters an object it does not understand. If strict is True,
              jsanitize will try to get the as_dict() attribute of the object. If
              no such attribute is found, an attribute error will be thrown. If
              strict is False, jsanitize will simply call str(object) to convert
              the object to a string representation.
          allow_bson (bool): This parameters sets the behavior when jsanitize
              encounters an bson supported type such as objectid and datetime. If
              True, such bson types will be ignored, allowing for proper
              insertion into MongoDb databases.
  
      Returns:
          Sanitized dict that can be json serialized.
      """
      if allow_bson and (isinstance(obj, (datetime.datetime, bytes)) or \
                         (bson is not None and isinstance(obj,
                                                          bson.objectid.ObjectId))):
          return obj
      if isinstance(obj, (list, tuple)):
          return [jsanitize(i, strict=strict, allow_bson=allow_bson) for i in obj]
      elif np is not None and isinstance(obj, np.ndarray):
          return [jsanitize(i, strict=strict, allow_bson=allow_bson) for i in
                  obj.tolist()]
      elif isinstance(obj, dict):
          return {k.__str__(): jsanitize(v, strict=strict, allow_bson=allow_bson)
                  for k, v in obj.items()}
      elif isinstance(obj, six.integer_types + tuple([float])):
          return obj
      elif obj is None:
          return None
  
      else:
          if not strict:
              return obj.__str__()
          else:
              if isinstance(obj, six.string_types):
                  return obj.__str__()
              else:
                  return jsanitize(obj.as_dict(), strict=strict,
                                   allow_bson=allow_bson)