MergeJSON JSONToArray UTF-8 and UTF-8 BOM character encoding

This is the place to get technical support and discuss all things to do with MergEXT

Moderators: FourthWorld, heatherlaine, Klaus, robinmiller, monte

Post Reply
marcha
Posts: 5
Joined: Wed Mar 03, 2010 1:15 pm

MergeJSON JSONToArray UTF-8 and UTF-8 BOM character encoding

Post by marcha » 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.

Code: Select all

put url ("file:" & tFile) into tRawData
put JSONToArray(tData) into gArray
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.

Code: Select all

put url ("file:" & tFile) into tRawData
put textEncode(tRawData,"UTF-8") into tData
put JSONToArray(tData) into gArray
Hope this helps somebody down the line..

Post Reply

Return to “MergEXT”