Hi
I store a tag JSON config in my MySQL DB. When I get it in a script and use system.util.jsonDecode() I have some trouble in my alarm name.
My tag JSON stored in DB :
"name": "Conso réelle supérieure à l'attendue (3j cumulés)"
The same alarm name in my created tag :
Thanks for your help
Try:
"name": u"Conso réelle supérieure à l'attendue (3j cumulés)"
I can’t do that because I get my tag json config from my DB. So alarm_name is stored in a variable.
tagCnf = system.db.runScalarQuery("SELECT jsonConfig FROM alarms WHERE id = 1")
tagCnf = system.util.jsonDecode(tagCnf)
system.tag.configure(baseTagPath,[tagCnf],"o")
Does your database column that stores your json have a unicode compatible encoding set up? Like UTF-8?
My table config below :
When I want to change “config” encoding in utf8_general_ci, it shows me message below.
You’ll have to look in MySQL docs how to deal with that. You may even have to re-create the DB with option for another character set, IIRC.
Maybe someone else here who likes MySQL will chime in.
flavien
January 27, 2022, 11:34am
7
It works when using SELECT CONVERT(jsonConfig USING utf8)
in your query.
It works too for INSERT and UPDATE statements.
1 Like