MergeJSON JSONToArray UTF-8 and UTF-8 BOM character encoding
Posted: Sat May 01, 2021 12:16 pm
Hi community,
I just needed to share this in case you come across the same issue:
I used the following lines to process JSON files in Livecode and the stack worked.
Over night the JSON files I was receiving weren't opening anymore in Livecode.
I couldn't understand as the online file checkers were showing me no issues with my JSON formatted text I was copy pasting into the browser.
Livecode debugger was escaping at the line JSONToArray without showing errors or providing hints.
I checked the JSON files with Notepad++, there is a helpful feature in Notepad++ which shows you the file encoding and there I noticed UTF-8 BOM encoded.
You can change the encoding in Notepad++ by Menu>Encoding>UTF-8
After re-saving the file Notepad++ as UTF-8 "only" I could now process the files in Livecode
After reading the forums I realized I could use textDecode in Livecode and this option works too and is obviously the better solution.
Hope this helps somebody down the line..
I just needed to share this in case you come across the same issue:
I used the following lines to process JSON files in Livecode and the stack worked.
Over night the JSON files I was receiving weren't opening anymore in Livecode.
I couldn't understand as the online file checkers were showing me no issues with my JSON formatted text I was copy pasting into the browser.
Livecode debugger was escaping at the line JSONToArray without showing errors or providing hints.
Code: Select all
put url ("file:" & tFile) into tRawData
put JSONToArray(tData) into gArray
You can change the encoding in Notepad++ by Menu>Encoding>UTF-8
After re-saving the file Notepad++ as UTF-8 "only" I could now process the files in Livecode
After reading the forums I realized I could use textDecode in Livecode and this option works too and is obviously the better solution.
Code: Select all
put url ("file:" & tFile) into tRawData
put textEncode(tRawData,"UTF-8") into tData
put JSONToArray(tData) into gArray