Matt Maier wrote:

> This code:
>
>    put "12345" into tArray["one"][1]
>    put "12345" into tArray["one"][2]
>    put "12345" into tArray["one"][3]
>    put "12345" into tArray["two"][1]
>    put "12345" into tArray["two"][2]
>    put jsonfromarray(tArray) into tWhatever
>
> gives me this result:
>
> {"one":{"3":12345,"1":12345,"2":12345},"two":{"1":12345,"2":12345}}
>
> which is a multi-level array, rather than this, which is a
> single-level array with lists
>
> {"one":["12345","12345","12345"],"two":["12345","12345"]}
>
> I'm not even sure how to distinguish between the two in Livecode. We
> parse strings into lists so often that I'm not aware of a pure list
> data structure. Livecode can interpret "12345,12345,12345" as a list
> if I tell it to go by item, but it's just a string and that's how
> easyJSON is treating it, as one string, not a list of strings.

I think you hit on the core of the issue:  LiveCode Script does not
(yet) support true lists.

xTalks have traditionally approached that with strings, as you noted, and with the efficiency and ease of chunk expressions that's not a bad way to handle things.

But it becomes problematic when trying to move data between systems using a data structure like JSON designed specifically for JavaScript.

I believe LiveCode Builder supports true lists.

It would be nice of some of the language features in LC Builder that are also common in other languages could be migrated into LC Script as well.

As an interim workaround, I suppose you could write your own LCArrayToJSON function that handles the specific use cases you're looking for, but that's tedious and would need to be written and used carefully with specific tasks in mind.

--
 Richard Gaskin
 Fourth World Systems
 Software Design and Development for the Desktop, Mobile, and the Web
 ____________________________________________________________________
 ambassa...@fourthworld.com                http://www.FourthWorld.com

_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to