Unicode Store in JSON

Monte Goulding monte at appisle.net
Sun Oct 14 20:54:48 EDT 2018



> On 15 Oct 2018, at 11:35 am, Sannyasin Brahmanathaswami via use-livecode <use-livecode at lists.runrev.com> wrote:
> 
> Wow, that worked! And I thought that JSON could not be a container for
> "binaryData" as described on the dictionary.

Could you provide some detail where the docs are misleading. It is actually true that you can’t JSON encode binary data.

We do have different libraries that treat JSON text encoding differently. mergJSON and therefore ArrayToJSON and JSONToArray deal with UTF-8 encoded JSON only. ArrayToJSON and JSONToArray will do this encoding for you if you give it text strings. If you give it binary strings then they must be UTF-8 encoded already otherwise mergJSON will throw an error.

JSONImport and JSONExport on the other hand deals with JSON as text so you need to textDecode/textDecode as a separate operation. If you give any LCB API binary strings when it is expecting text strings then it will follow the engine’s standard conversion which will be native encoding (eg ISO/MacRoman).

Note while the previous JSON specs just say unicode encoding can be used RFC8259 specifies UTF-8 encoding of JSON between systems.

Cheers

Monte


More information about the use-livecode mailing list