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
"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)
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.
It works when using
SELECT CONVERT(jsonConfig USING utf8) in your query.
It works too for INSERT and UPDATE statements.