Decoding json in Desktop UI

Find and share HowTos to various installations / configurations!
Search

Post Reply
7 posts • Page 1 of 1
Mgiacome
Posts: 20
Joined: Thu Sep 26, 2024 1:35 pm

Decoding json in Desktop UI

Post by Mgiacome »

Hi, I would report a strange behaviour of winccoa clients. In some panels I have scripts that load information from a json file (fileToString and jsonDecode functions used), in ULC clients it's all ok, json is parsed correctly and everything run smoothly.

When I use Desktop UI client, it doesn't work at all, from different PC, also on the same winccoa server, no debug information. In log view I can see it downloads succesfully the json file from the scripts dir.

After many tries, I've been able to get a message from the fileToString function, used on a very simple json file "{"TEST":"TEST"}, and it's something like "WINCCOA_CRYPTED_SCRIPT 2 |������{��M�T���N1��(^N�GX�]

Do I have to enable some config in [ui] section ? Desktop UI is able tu run all the default libs functions ? Is it only a problem of encoding (changing "UTF8" o "ISO88591" return different symbols .....) ?

Thanks

User avatar
kilianvp
Posts: 443
Joined: Fri Jan 16, 2015 10:29 am

Re: Decoding json in Desktop UI

Post by kilianvp »

"WINCCOA_CRYPTED_SCRIPT 2" indicates that the file got encrypted.

Dont put your JSON files below the "panels" and "scripts" folder.

autoEncryption (which is on per default) encryptes all files below the "panels" and "scripts" folder.

https://www.winccoa.com/documentation/W ... Encryption

Mgiacome
Posts: 20
Joined: Thu Sep 26, 2024 1:35 pm

Re: Decoding json in Desktop UI

Post by Mgiacome »

Thanks for the reply, really useful. Something odd happens in Desktop UI, cause it downloads json files from the scripts/libs folder by default (and they are encrypted), now I'm trying to figure out how to tell it the correct folder /data/mappings/filejson.json

Mgiacome
Posts: 20
Joined: Thu Sep 26, 2024 1:35 pm

Re: Decoding json in Desktop UI

Post by Mgiacome »

[SOLVED]

So thanks to killian, I've moved my json files to the /data folder (so they are not encrypted).

Inside my scripts I've changed the path to something like

Code: Select all

string path = getPath(DATA_REL_PATH); fileToString(path + "mappings/example.json", jsonData); 
Then I've set

Code: Select all

autoUpdataDir = "data/mappings"
in the config file, [ui] section, so the Desktop UI client downloads those resources at the beginning of the communication with server

User avatar
leoknipp
Posts: 2926
Joined: Tue Aug 24, 2010 7:28 pm

Re: Decoding json in Desktop UI

Post by leoknipp »

We suggest not use the autoUpdateDir config entry if the data/mappings directory possibly contains a lot of files/data.
It will delay every startup of the UI.
With the function getPath() you can load files from the server to the client during runtime.

Best Regards
Leopold Knipp
Senior Support Specialist

Mgiacome
Posts: 20
Joined: Thu Sep 26, 2024 1:35 pm

Re: Decoding json in Desktop UI

Post by Mgiacome »

Thanks Leo, I saw in the logs that the startup time on the client is only a couple of seconds slower than before. Also, using only getPath without autoUpdateDir doesn’t seem to be sufficient to load files during runtime

gschijndel
Posts: 373
Joined: Tue Jan 15, 2019 3:12 pm

Re: Decoding json in Desktop UI

Post by gschijndel »

Try this:

Code: Select all

string path = getPath(DATA_REL_PATH, "mappings/example.json"); fileToString(path, jsonData); 
The function 'getPath' only downloads a specific file to the client (not whole directories).

Post Reply
7 posts • Page 1 of 1