TextDecode JSON array
Peter TB Brett
peter.brett at livecode.com
Sun Jan 22 02:26:02 EST 2017
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".
Peter
--
Dr Peter Brett <peter.brett at livecode.com>
LiveCode Technical Project Manager
lcb-mode for Emacs: https://github.com/peter-b/lcb-mode
More information about the use-livecode
mailing list