TextDecode JSON array

J. Landman Gay jacque at hyperactivesw.com
Sun Jan 22 21:31:27 CET 2017

On 1/22/17 1:26 AM, Peter TB Brett via use-livecode wrote:
> On 22/01/2017 03:22, J. Landman Gay via use-livecode wrote:
>> Here's a test sample of some UTF8 I get back from a server:
>>   {"UserID":48,"UserName":"Eduardo Ba\u00f1uls","UserLoginName":"ebanu"}
> Hi Jacque,
> This is valid JSON (and also valid ASCII).  In JSON, any character in a
> string may be encoded in the form \uXXXX where XXXX is the 4-digit
> hexadecimal representation of a Unicode codepoint.  No textDecode()
> operation is required.
> JSONImport() handles this correctly.
> 1) Create a stack with a field and a button
> 2) Put the text above into the field
> 3) Set the script of the button to:
>> local tJson
>> put JSONImport(field 1) into tJson
>> answer tJson["UserName"]
> 4) Enter browse mode and click the button
> You will get an answer dialog displaying "Eduardo Bañuls".

Thank you, and Trevor also, for this. I hadn't heard of importJSON() 
before but it seems to be what I need. I'll take Trevor's advice and 
textDecode the JSON before running it through JSONImport(). All the 
incoming data is being decoded already anyway so I'll just leave that in 

Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com

More information about the use-livecode mailing list