code: def json_compat_obj_encode(data_type, obj, caller_permissions=None, alias_validators=None,
                             old_style=False, for_msgpack=False, should_redact=False):
      
      serializer = StoneToPythonPrimitiveSerializer(
          caller_permissions, alias_validators, for_msgpack, old_style, should_redact)
      return serializer.encode(data_type, obj)
docs: Encodes an object into a JSON-compatible dict based on its type.
  
      Args:
          data_type (Validator): Validator for obj.
          obj (object): Object to be serialized.
          caller_permissions (list): The list of raw-string caller permissions
              with which to serialize.
  
      Returns:
          An object that when passed to json.dumps() will produce a string
          giving the JSON-encoded object.
  
      See json_encode() for additional information about validation.