Define fields in log4j.xml

I am trying to craete the pipeline…

rule "Severity Mapper"
    when 
    has_field("level")
    then 
    let mapping = { 0: "FATAL (0)", 1: "Alert (1)", 2: "SEVERE (2)", 3: "ERROR (3)", 4: "WARNING (4)", 5: "Notice (5)", 6: "INFO (6)", 7: "DEBUG (7)"};
    set_field("Severity", mapping[to_string($message.level)]);
    end

but it is giving an error

mismatched input '0' expecting {'}' , identifier

Please let me know what is syntax error here.