Conditional creation of part of JSON file

Hi. I`m trying to create json template file for emr security configuration. Currently I have the following:

 resource "aws_emr_security_configuration" "this" {
      name = "test-configuration"
      configuration = jsonencode({
          "EncryptionConfiguration": {
            "EnableInTransitEncryption": var.emr_in_transit_encryption_enabled,
            "EnableAtRestEncryption": var.emr_at_rest_encryption_enabled
            "InTransitEncryptionConfiguration": {
              "TLSCertificateConfiguration": {
                "CertificateProviderType": "PEM",
                "S3Object": local.emr_s3_object
              }
            },
            "AtRestEncryptionConfiguration": {
              "S3EncryptionConfiguration": {
                "EncryptionMode": "SSE-KMS",
                "AwsKmsKey": var.kms_key_arn
              },
              "LocalDiskEncryptionConfiguration": {
                "EnableEbsEncryption": true,
                "EncryptionKeyProviderType": "AwsKms",
                "AwsKmsKey": var.kms_key_arn
              }
            }
          }
       })
 }

I want that depends on var.emr_in_transit_encryption_enabled variable (true or false) add or remove the following part:

"InTransitEncryptionConfiguration": {
  "TLSCertificateConfiguration": {
    "CertificateProviderType": "PEM",
    "S3Object": local.emr_s3_object
  }
}

I tried

%{ if var.emr_in_transit_encryption_enabled}
"InTransitEncryptionConfiguration": {
  "TLSCertificateConfiguration": {
    "CertificateProviderType": "PEM",
    "S3Object": local.emr_s3_object
  }
}
{endif} 

but it does not work
Is it possible to do that?

Hi, is there any valid configuration to use conditional expression inside JSON template file?