how to create a list in easyJSON

Mark Wieder ahsoftware at sonic.net
Sat Dec 31 19:17:22 EST 2016


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
  ahsoftware at gmail.com





More information about the use-livecode mailing list