Use MQTT Topic names as database names

Hi,
Am using telegraf.conf file to connect to 2-3 MQTT topics at a time. How can I use those topic names as my Measurement names in the database when sending data in json format?
I tried using if-else in the conf file but am getting error.

[[inputs.mqtt_consumer]]
servers = [“localhost:1883”]
##servers = [“10.255.201.118:1883”]

MQTT QoS, must be 0, 1, or 2

qos = 0

Topics to subscribe to

topics = [
“Lenze”,
“DIAG”,
“ASSET”,
“EVENT”,
“PROCESS”,
“CONNECT”
]

if [[topics=~“Lenze”]]; then
name_override = “Lenze”
fi
if [[topics=~“DIAG”]]; then
name_override = “DIAG”
fi