Re: how to create a list in easyJSON

2017-01-08 Thread pink via use-livecode
In the most recent version of easyJSON, numeric keyed arrays will turn into
JSON arrays, older versions may vary. 

fastJSON does this by default, but it can be overridden by passing true into
the keepNumeric parameter: 
arrayToJson(pArrayData, keepNumeric) 

for example: 
put arrayToJSON(inputArray,true) into jsonOutput 


hh via use-livecode wrote
> As a warning for others, fastJSON is not directly interchangeable with
> easyJSON.
> 
> I'm using a big array that has a couple levels of numeric keys before you
> get to the text keys. When fastJSON converts the array to JSON it throws
> out the numeric keys and just turns everything into a list.
> 
> I don't think that would actually be a problem, except that in my data
> structure the [0] key has important metadata in it and when fastJSON
> converts back from JSON to an array it doesn't start counting at 0, so all
> of the data comes back but it's offset.
> 
> At least, this is the newest version of fastJSON from github and some old
> version of easyJSON that I've had around for a long time (not sure what
> version it is).
> 
> On Tue, Jan 3, 2017 at 8:05 AM, Bob Sneidar 

> bobsneidar@

> 
> wrote:
> 
>> Hmmm... all of this may explain why a table in a PDF fillable form breaks
>> the controls out as columns, not records. So when populating an FDF file,
>> my data needs to have each column in it's own variable, or else I have to
>> do nested repeats to place it all correctly.
>>
>> Bob S
>>
>>
>>
>> ___
>> use-livecode mailing list
>> 

> use-livecode@.runrev

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

> use-livecode@.runrev

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





--
View this message in context: 
http://runtime-revolution.278305.n4.nabble.com/how-to-create-a-list-in-easyJSON-tp4711279p4711515.html
Sent from the Revolution - User mailing list archive at Nabble.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


Re: how to create a list in easyJSON

2017-01-08 Thread pink via use-livecode
In the most recent version of easyJSON, numeric keyed arrays will turn into
JSON arrays, older versions may vary.

fastJSON does this by default, but it can be overridden by passing true into
the keepNumeric parameter:
arrayToJson(pArrayData, keepNumeric)

for example:
put arrayToJSON(myArray,true) into jsonOutput






--
View this message in context: 
http://runtime-revolution.278305.n4.nabble.com/how-to-create-a-list-in-easyJSON-tp4711279p4711513.html
Sent from the Revolution - User mailing list archive at Nabble.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


Re: how to create a list in easyJSON

2017-01-07 Thread Matt Maier via use-livecode
As a warning for others, fastJSON is not directly interchangeable with
easyJSON.

I'm using a big array that has a couple levels of numeric keys before you
get to the text keys. When fastJSON converts the array to JSON it throws
out the numeric keys and just turns everything into a list.

I don't think that would actually be a problem, except that in my data
structure the [0] key has important metadata in it and when fastJSON
converts back from JSON to an array it doesn't start counting at 0, so all
of the data comes back but it's offset.

At least, this is the newest version of fastJSON from github and some old
version of easyJSON that I've had around for a long time (not sure what
version it is).

On Tue, Jan 3, 2017 at 8:05 AM, Bob Sneidar 
wrote:

> Hmmm... all of this may explain why a table in a PDF fillable form breaks
> the controls out as columns, not records. So when populating an FDF file,
> my data needs to have each column in it's own variable, or else I have to
> do nested repeats to place it all correctly.
>
> Bob S
>
>
>
> ___
> 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
>
___
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


Re: how to create a list in easyJSON

2017-01-03 Thread Bob Sneidar
Hmmm... all of this may explain why a table in a PDF fillable form breaks the 
controls out as columns, not records. So when populating an FDF file, my data 
needs to have each column in it's own variable, or else I have to do nested 
repeats to place it all correctly. 

Bob S



___
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


Re: how to create a list in easyJSON

2017-01-02 Thread J. Landman Gay

On 1/1/17 12:31 PM, pink wrote:

what version of easyJSON are you using? I just copied the library from:
https://github.com/luxlogica/easyjson/blob/master/easyjson.lc

used 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
and got:
{"one":[12345,12345,12345],"two":[12345,12345]}


I still recommend fastJSON over easyJSON:
https://github.com/bhall2001/fastjson/blob/master/fastjson.lc


The built-in arrayToJSON function gives the same thing.

--
Jacqueline Landman Gay | jac...@hyperactivesw.com
HyperActive Software   | http://www.hyperactivesw.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


Re: how to create a list in easyJSON

2017-01-01 Thread pink
check the script...

there should be a function:  isNumericalArray

this is the function which appears to be either not there, or is not
functioning correctly



--
View this message in context: 
http://runtime-revolution.278305.n4.nabble.com/how-to-create-a-list-in-easyJSON-tp4711279p4711304.html
Sent from the Revolution - User mailing list archive at Nabble.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


Re: how to create a list in easyJSON

2017-01-01 Thread Matt Maier
That's a good question. The stack doesn't have a version number in it, at
least not that I found.

On Sun, Jan 1, 2017 at 10:31 AM, pink  wrote:

> what version of easyJSON are you using? I just copied the library from:
> https://github.com/luxlogica/easyjson/blob/master/easyjson.lc
>
> used 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
> and got:
> {"one":[12345,12345,12345],"two":[12345,12345]}
>
>
> I still recommend fastJSON over easyJSON:
> https://github.com/bhall2001/fastjson/blob/master/fastjson.lc
>
>
>
> --
> View this message in context: http://runtime-revolution.
> 278305.n4.nabble.com/how-to-create-a-list-in-easyJSON-
> tp4711279p4711302.html
> Sent from the Revolution - User mailing list archive at Nabble.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
>
___
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


Re: how to create a list in easyJSON

2017-01-01 Thread pink
what version of easyJSON are you using? I just copied the library from:
https://github.com/luxlogica/easyjson/blob/master/easyjson.lc

used 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 
and got:
{"one":[12345,12345,12345],"two":[12345,12345]}


I still recommend fastJSON over easyJSON:
https://github.com/bhall2001/fastjson/blob/master/fastjson.lc



--
View this message in context: 
http://runtime-revolution.278305.n4.nabble.com/how-to-create-a-list-in-easyJSON-tp4711279p4711302.html
Sent from the Revolution - User mailing list archive at Nabble.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


Re: how to create a list in easyJSON

2016-12-31 Thread Mark Wieder

On 12/30/2016 05:27 PM, Matt Maier wrote:

I'm trying to send a list of strings to an API. Best I can tell it's
interpreting the entire list as one string. Is there a way to send data to
easyJSON such that it returns a JSON  list of strings instead of one
monolithic string?

For example, I've got something like this:

array[one] = 12345,12345,12345
array[two] = 12345,12345

and what I get back from easyJSON is this:

{"one":"12345,12345,12345","two":"12345,12345"}

when what I'm trying to get is more like this

{"one":["12345","12345","12345"],"two":["12345","12345"]}


Well, technically this isn't really a "problem"...
The json object you're returning is exactly what you put into the array.
The first is a string of 17 characters, the second of 11 characters.
The commas are just characters in a string, nothing special.

However, as both you and Richard point out, LC's lack of true strings is 
limiting.


You might try something like this:

   put 12345,"hello",12345 into tElement
   split tElement by comma
   put tElement into tArray["one"]
   put 12345,12345 into tElement
   split tElement by comma
   put tElement into tArray["two"]
   put jsonFromArray(tArray)

result: {"one":[12345,"hello",12345],"two":[12345,12345]}

Q: Do you really want the numeric values quoted in the json object?

--
 Mark Wieder
 ahsoftw...@gmail.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


Re: how to create a list in easyJSON

2016-12-31 Thread Richard Gaskin

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.comhttp://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


Re: how to create a list in easyJSON

2016-12-31 Thread Matt Maier
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.

On Sat, Dec 31, 2016 at 10:08 AM, pink  wrote:

> in a nutshell, easyJSON creates what you want by using numeric keys
>
> so:
> array[one][1] = 12345
> array[one][2] = 12345
> array[one][3] = 12345
> array[two][1] = 12345
> array[two][2] = 12345
>
> would produce the results you are looking for (technically the numbers
> don't
> have to be sequential, it just has to be that all of the keys must be
> numeric)
>
>
>
> --
> View this message in context: http://runtime-revolution.
> 278305.n4.nabble.com/how-to-create-a-list-in-easyJSON-
> tp4711279p4711289.html
> Sent from the Revolution - User mailing list archive at Nabble.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
>
___
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


Re: how to create a list in easyJSON

2016-12-31 Thread pink
in a nutshell, easyJSON creates what you want by using numeric keys

so:
array[one][1] = 12345
array[one][2] = 12345
array[one][3] = 12345
array[two][1] = 12345
array[two][2] = 12345

would produce the results you are looking for (technically the numbers don't
have to be sequential, it just has to be that all of the keys must be
numeric)



--
View this message in context: 
http://runtime-revolution.278305.n4.nabble.com/how-to-create-a-list-in-easyJSON-tp4711279p4711289.html
Sent from the Revolution - User mailing list archive at Nabble.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


Re: how to create a list in easyJSON

2016-12-31 Thread Richard Gaskin

Matt Maier wrote:
...
> when what I'm trying to get is more like this
>
> {"one":["12345","12345","12345"],"two":["12345","12345"]}

Let's look at the other side of that and see if we can find a good 
round-trip solution:  What would the string you have above look like in 
a LiveCode array?


--
 Richard Gaskin
 Fourth World Systems
 Software Design and Development for the Desktop, Mobile, and the Web
 
 ambassa...@fourthworld.comhttp://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


Re: how to create a list in easyJSON

2016-12-30 Thread Matt Maier
   put "12345,12345,12345" into tArray["one"]
   put "12345,12345" into tArray["two"]
   split tArray["one"] by comma
   put jsonfromarray(tArray) into tWhatever

result

{"one":{"3":12345,"1":12345,"2":12345},"two":"12345,12345"}

So looks like that just created an array with a numeric index, which is
preserved in the JSON conversion.

On Fri, Dec 30, 2016 at 10:12 PM, Andre Garzia 
wrote:

> Try placing a:
>
>   Split tArray[one] by comma
>
> Before converting to json.
>
> Om om
> Andre
> Ps: typing on the phone, sorry for my brevity
>
> Em 30 de dez de 2016 15:29, "Matt Maier"  escreveu:
>
> > I'm trying to send a list of strings to an API. Best I can tell it's
> > interpreting the entire list as one string. Is there a way to send data
> to
> > easyJSON such that it returns a JSON  list of strings instead of one
> > monolithic string?
> >
> > For example, I've got something like this:
> >
> > array[one] = 12345,12345,12345
> > array[two] = 12345,12345
> >
> > and what I get back from easyJSON is this:
> >
> > {"one":"12345,12345,12345","two":"12345,12345"}
> >
> > when what I'm trying to get is more like this
> >
> > {"one":["12345","12345","12345"],"two":["12345","12345"]}
> > ___
> > 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
> >
> ___
> 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
>
___
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


Re: how to create a list in easyJSON

2016-12-30 Thread Andre Garzia
Try placing a:

  Split tArray[one] by comma

Before converting to json.

Om om
Andre
Ps: typing on the phone, sorry for my brevity

Em 30 de dez de 2016 15:29, "Matt Maier"  escreveu:

> I'm trying to send a list of strings to an API. Best I can tell it's
> interpreting the entire list as one string. Is there a way to send data to
> easyJSON such that it returns a JSON  list of strings instead of one
> monolithic string?
>
> For example, I've got something like this:
>
> array[one] = 12345,12345,12345
> array[two] = 12345,12345
>
> and what I get back from easyJSON is this:
>
> {"one":"12345,12345,12345","two":"12345,12345"}
>
> when what I'm trying to get is more like this
>
> {"one":["12345","12345","12345"],"two":["12345","12345"]}
> ___
> 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
>
___
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


how to create a list in easyJSON

2016-12-30 Thread Matt Maier
I'm trying to send a list of strings to an API. Best I can tell it's
interpreting the entire list as one string. Is there a way to send data to
easyJSON such that it returns a JSON  list of strings instead of one
monolithic string?

For example, I've got something like this:

array[one] = 12345,12345,12345
array[two] = 12345,12345

and what I get back from easyJSON is this:

{"one":"12345,12345,12345","two":"12345,12345"}

when what I'm trying to get is more like this

{"one":["12345","12345","12345"],"two":["12345","12345"]}
___
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