jsonImport or JSONToArray

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

jsonImport or JSONToArray

Geoff Canyon via use-livecode
Has anyone recently tried to create a standalone app which includes either a jsonImport or JSONToArray call?

While my code works perfectly when run within the LC API, once a standalone is produced, it chokes  on either one of these calls.  I've reduced the code to its bare essentials.  A sample/simple JSON string I am trying is:

{
 "array": [
   1,
   2,
   3
 ],
 "boolean": true,
 "null": null,
 "number": 123,
 "object": {
   "a": "b",
   "c": "d",
   "e": "f"
 },
 "string": "Hello World"
}

This string is embedded as a Custom Property within a button.  The button calls the following:

on mouseUp

// just empty everything to make sure things are in a known state

     put empty into temp
     put empty into tArray
     put empty into dispArray
     put empty into tJson
     
     get the json of button "ThingSpeak_Fetch"
     put it into testJson
     
// display the JSON before it is converted into an array

     answer "Simple JSON example:" & cr & testJson
     
// this line (either "version") will choke the standalone... it doesn't lock it up in the API

     put JsonToArray(testJson) into tArray
     //put jsonImport(testJson) into tArray
     
     put displayArrayData(tArray,  "") into dispArray
     answer dispArray

end mouseUp

function displayArrayData pArray, pIndent
     # create the variable that loops through the keys in the array
     local tKey
     if pArray is an array then
          # print information to indicate that we are entering a new nested level of the array
          get "Array" & return
          # print full stops that allow the reader to track the depth of an element
          put "." after pIndent
          # create the indentation
          put tab after pIndent
          repeat for each key tKey in pArray
               # call displayArrayData with a nested array
               put format("%s[%s] => %s\n", pIndent, tKey, displayArrayData (pArray[tKey], pIndent)) after it
          end repeat
          delete the last char of it
          return it
     else
          return pArray
     end if
end displayArrayData

The function call simply outputs the converted array.... and will do so when this code is run from within the API ... but create a Windows standalone and the array output is never generated.

I've tried this in Windows 7 Enterprise SP1, LC: 8.1.9, 8.1.10 and 9.0.1 ... also tried on MAC Sierra (10.12.6) and LC 8.1.9

All platforms behave identically as described above

Any help would be appreciated... meanwhile I'll be submitting this to LC directly

Douglas Ruisaard
Trilogy Software
(250) 573-3935




_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: jsonImport or JSONToArray

Geoff Canyon via use-livecode
Douglas,

did you try to select the inclusions manually in StandaloneBuilder settings?

I might be wrong, but i think i remember there was a problem with including that library when “searching for inclusions” was selected in the SB settings.

Regards,
Matthias


Matthias Rebbe

free tools for Livecoders:
https://instamaker.dermattes.de <https://instamaker.dermattes.de/>
https://winsignhelper.dermattes.de <https://winsignhelper.dermattes.de/>

> Am 22.10.2018 um 00:45 schrieb Douglas Ruisaard via use-livecode <[hidden email] <mailto:[hidden email]>>:
>
> Has anyone recently tried to create a standalone app which includes either a jsonImport or JSONToArray call?
>
> While my code works perfectly when run within the LC API, once a standalone is produced, it chokes  on either one of these calls.  I've reduced the code to its bare essentials.  A sample/simple JSON string I am trying is:
>
> {
> "array": [
>   1,
>   2,
>   3
> ],
> "boolean": true,
> "null": null,
> "number": 123,
> "object": {
>   "a": "b",
>   "c": "d",
>   "e": "f"
> },
> "string": "Hello World"
> }
>
> This string is embedded as a Custom Property within a button.  The button calls the following:
>
> on mouseUp
>
> // just empty everything to make sure things are in a known state
>
>     put empty into temp
>     put empty into tArray
>     put empty into dispArray
>     put empty into tJson
>
>     get the json of button "ThingSpeak_Fetch"
>     put it into testJson
>
> // display the JSON before it is converted into an array
>
>     answer "Simple JSON example:" & cr & testJson
>
> // this line (either "version") will choke the standalone... it doesn't lock it up in the API
>
>     put JsonToArray(testJson) into tArray
>     //put jsonImport(testJson) into tArray
>
>     put displayArrayData(tArray,  "") into dispArray
>     answer dispArray
>
> end mouseUp
>
> function displayArrayData pArray, pIndent
>     # create the variable that loops through the keys in the array
>     local tKey
>     if pArray is an array then
>          # print information to indicate that we are entering a new nested level of the array
>          get "Array" & return
>          # print full stops that allow the reader to track the depth of an element
>          put "." after pIndent
>          # create the indentation
>          put tab after pIndent
>          repeat for each key tKey in pArray
>               # call displayArrayData with a nested array
>               put format("%s[%s] => %s\n", pIndent, tKey, displayArrayData (pArray[tKey], pIndent)) after it
>          end repeat
>          delete the last char of it
>          return it
>     else
>          return pArray
>     end if
> end displayArrayData
>
> The function call simply outputs the converted array.... and will do so when this code is run from within the API ... but create a Windows standalone and the array output is never generated.
>
> I've tried this in Windows 7 Enterprise SP1, LC: 8.1.9, 8.1.10 and 9.0.1 ... also tried on MAC Sierra (10.12.6) and LC 8.1.9
>
> All platforms behave identically as described above
>
> Any help would be appreciated... meanwhile I'll be submitting this to LC directly
>
> Douglas Ruisaard
> Trilogy Software
> (250) 573-3935
>
>
>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email] <mailto:[hidden email]>
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: jsonImport or JSONToArray

Geoff Canyon via use-livecode
In reply to this post by Geoff Canyon via use-livecode
Thanks for the reply, Matthias.  Yes... I forgot to include the fact that I also tested BOTH with the "default" setting for Inclusions (LC finds them) and selecting the JSON library, manually.  I've tried to keep the demonstration code simple, so I only tried to "include" the "JSON Library" (but also the "Answer Dialog" and "Ask Dialog" were checked by LC) ... should I also include something else?

The fact that BOTH functions (jsonImport and JsonToArray) fail (assuming they actually call different code within LC) may be significant.

Can you or someone try the code I provided in both scenarios (within development and as a standalone), please?  As I stated, I have tried it on BOTH Windows and MAC OS resulting in the same choke point.  You could do as I did (apparent in the code) and create a Custom Key within the button (I called the button "ThingSpeak_Fetch") with the custom key as "json" and the value being the JSON string (which you could cut and paste into the key's value from this message)

Douglas Ruisaard
Trilogy Software
(250) 573-3935

>
> Douglas,
>
> did you try to select the inclusions manually in StandaloneBuilder settings?
>
> I might be wrong, but i think i remember there was a problem with including that library when
> ?searching for inclusions? was selected in the SB settings.
>
> Regards,
> Matthias
>
>
> Matthias Rebbe
>
> free tools for Livecoders:
> https://instamaker.dermattes.de <https://instamaker.dermattes.de/>
> https://winsignhelper.dermattes.de <https://winsignhelper.dermattes.de/>
> > Am 22.10.2018 um 00:45 schrieb Douglas Ruisaard via use-livecode <[hidden email]
> <mailto:[hidden email]>>:
> >
> > Has anyone recently tried to create a standalone app which includes either a jsonImport or JSONToArray call?
> >
> > While my code works perfectly when run within the LC API, once a standalone is produced, it chokes
> > on either one of these calls.  I've reduced the code to its bare essentials.  A sample/simple JSON
> > string I am trying is:
> >
> > {
> > "array": [
> >   1,
> >   2,
> >   3
> > ],
> > "boolean": true,
> > "null": null,
> > "number": 123,
> > "object": {
> >   "a": "b",
> >   "c": "d",
> >   "e": "f"
> > },
> > "string": "Hello World"
> > }
> >
> > This string is embedded as a Custom Property within a button.  The button calls the following:
> >
> > on mouseUp
> >
> > // just empty everything to make sure things are in a known state
> >
> >     put empty into temp
> >     put empty into tArray
> >     put empty into dispArray
> >     put empty into tJson
> >
> >     get the json of button "ThingSpeak_Fetch"
> >     put it into testJson
> >
> > // display the JSON before it is converted into an array
> >
> >     answer "Simple JSON example:" & cr & testJson
> >
> > // this line (either "version") will choke the standalone... it
> > //doesn't lock it up in the API
> >
> >     put JsonToArray(testJson) into tArray
> >     //put jsonImport(testJson) into tArray
> >
> >     put displayArrayData(tArray,  "") into dispArray
> >     answer dispArray
> >
> > end mouseUp
> >
> > function displayArrayData pArray, pIndent
> >     # create the variable that loops through the keys in the array
> >     local tKey
> >     if pArray is an array then
> >          # print information to indicate that we are entering a new nested level of the array
> >          get "Array" & return
> >          # print full stops that allow the reader to track the depth of an element
> >          put "." after pIndent
> >          # create the indentation
> >          put tab after pIndent
> >          repeat for each key tKey in pArray
> >               # call displayArrayData with a nested array
> >               put format("%s[%s] => %s\n", pIndent, tKey, displayArrayData (pArray[tKey], pIndent)) after it
> >          end repeat
> >          delete the last char of it
> >          return it
> >     else
> >          return pArray
> >     end if
> > end displayArrayData
> >
> > The function call simply outputs the converted array.... and will do so when this code is run from
> within the API ... but create a Windows standalone and the array output is never generated.
> >
> > I've tried this in Windows 7 Enterprise SP1, LC: 8.1.9, 8.1.10 and
> > 9.0.1 ... also tried on MAC Sierra (10.12.6) and LC 8.1.9
> >
> > All platforms behave identically as described above
> >
> > Any help would be appreciated... meanwhile I'll be submitting this to
> > LC directly
> >
> > Douglas Ruisaard
> > Trilogy Software
> > (250) 573-3935
> >
> >
> >
> >
> > _______________________________________________
> > use-livecode mailing list
> > [hidden email] <mailto:[hidden email]>
> > Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> > http://lists.runrev.com/mailman/listinfo/use-livecode
>


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

RE: jsonImport or JSONToArray

Geoff Canyon via use-livecode
In reply to this post by Geoff Canyon via use-livecode
I've solved my issue.... using Matthias's "tip", I searched further into the available inclusions and found Monte's excellent mergJSON (I had opted out looking further once I found and checked the "JSON Libray" inclusion)... which has its own JsonToArray function.  Including mergeJSON manually got the standalone to function.

Thanks, Matthias!

Douglas Ruisaard
Trilogy Software
(250) 573-3935


> -----Original Message-----
> From: Douglas Ruisaard [mailto:[hidden email]]
> Sent: Monday, October 22, 2018 8:17 AM
> To: '[hidden email]'
> Subject: Re: jsonImport or JSONToArray
>
> Thanks for the reply, Matthias.  Yes... I forgot to include the fact that I also tested BOTH with the
> "default" setting for Inclusions (LC finds them) and selecting the JSON library, manually.  I've tried
> to keep the demonstration code simple, so I only tried to "include" the "JSON Library" (but also the
> "Answer Dialog" and "Ask Dialog" were checked by LC) ... should I also include something else?
>
> The fact that BOTH functions (jsonImport and JsonToArray) fail (assuming they actually call different
> code within LC) may be significant.
>
> Can you or someone try the code I provided in both scenarios (within development and as a standalone),
> please?  As I stated, I have tried it on BOTH Windows and MAC OS resulting in the same choke point.
> You could do as I did (apparent in the code) and create a Custom Key within the button (I called the
> button "ThingSpeak_Fetch") with the custom key as "json" and the value being the JSON string (which
> you could cut and paste into the key's value from this message)
>
> Douglas Ruisaard
> Trilogy Software
> (250) 573-3935
>
> >
> > Douglas,
> >
> > did you try to select the inclusions manually in StandaloneBuilder settings?
> >
> > I might be wrong, but i think i remember there was a problem with
> > including that library when ?searching for inclusions? was selected in the SB settings.
> >
> > Regards,
> > Matthias
> >
> >
> > Matthias Rebbe
> >
> > free tools for Livecoders:
> > https://instamaker.dermattes.de <https://instamaker.dermattes.de/>
> > https://winsignhelper.dermattes.de
> > <https://winsignhelper.dermattes.de/>
> > > Am 22.10.2018 um 00:45 schrieb Douglas Ruisaard via use-livecode
> > > <[hidden email]
> > <mailto:[hidden email]>>:
> > >
> > > Has anyone recently tried to create a standalone app which includes either a jsonImport or
> JSONToArray call?
> > >
> > > While my code works perfectly when run within the LC API, once a
> > > standalone is produced, it chokes on either one of these calls.
> > > I've reduced the code to its bare essentials.  A sample/simple JSON string I am trying is:
> > >
> > > {
> > > "array": [
> > >   1,
> > >   2,
> > >   3
> > > ],
> > > "boolean": true,
> > > "null": null,
> > > "number": 123,
> > > "object": {
> > >   "a": "b",
> > >   "c": "d",
> > >   "e": "f"
> > > },
> > > "string": "Hello World"
> > > }
> > >
> > > This string is embedded as a Custom Property within a button.  The button calls the following:
> > >
> > > on mouseUp
> > >
> > > // just empty everything to make sure things are in a known state
> > >
> > >     put empty into temp
> > >     put empty into tArray
> > >     put empty into dispArray
> > >     put empty into tJson
> > >
> > >     get the json of button "ThingSpeak_Fetch"
> > >     put it into testJson
> > >
> > > // display the JSON before it is converted into an array
> > >
> > >     answer "Simple JSON example:" & cr & testJson
> > >
> > > // this line (either "version") will choke the standalone... it
> > > //doesn't lock it up in the API
> > >
> > >     put JsonToArray(testJson) into tArray
> > >     //put jsonImport(testJson) into tArray
> > >
> > >     put displayArrayData(tArray,  "") into dispArray
> > >     answer dispArray
> > >
> > > end mouseUp
> > >
> > > function displayArrayData pArray, pIndent
> > >     # create the variable that loops through the keys in the array
> > >     local tKey
> > >     if pArray is an array then
> > >          # print information to indicate that we are entering a new nested level of the array
> > >          get "Array" & return
> > >          # print full stops that allow the reader to track the depth of an element
> > >          put "." after pIndent
> > >          # create the indentation
> > >          put tab after pIndent
> > >          repeat for each key tKey in pArray
> > >               # call displayArrayData with a nested array
> > >               put format("%s[%s] => %s\n", pIndent, tKey, displayArrayData (pArray[tKey],
> pIndent)) after it
> > >          end repeat
> > >          delete the last char of it
> > >          return it
> > >     else
> > >          return pArray
> > >     end if
> > > end displayArrayData
> > >
> > > The function call simply outputs the converted array.... and will do
> > > so when this code is run from
> > within the API ... but create a Windows standalone and the array output is never generated.
> > >
> > > I've tried this in Windows 7 Enterprise SP1, LC: 8.1.9, 8.1.10 and
> > > 9.0.1 ... also tried on MAC Sierra (10.12.6) and LC 8.1.9
> > >
> > > All platforms behave identically as described above
> > >
> > > Any help would be appreciated... meanwhile I'll be submitting this
> > > to LC directly
> > >
> > > Douglas Ruisaard
> > > Trilogy Software
> > > (250) 573-3935
> > >
> > >
> > >
> > >
> > > _______________________________________________
> > > use-livecode mailing list
> > > [hidden email] <mailto:[hidden email]>
> > > Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> > > http://lists.runrev.com/mailman/listinfo/use-livecode
> >


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: jsonImport or JSONToArray

Geoff Canyon via use-livecode
In reply to this post by Geoff Canyon via use-livecode
As you folks may have seen earlier today, I've shipped a new product
here on the list. While I was building the demo stack for this plugin, I
had the same problem as you describe. In my case it boiled down to the
automatic inclusions not working, I ended up needing to do manual
inclusions and then it worked.

On 10/21/2018 11:59 PM, Matthias Rebbe via use-livecode wrote:

> Douglas,
>
> did you try to select the inclusions manually in StandaloneBuilder settings?
>
> I might be wrong, but i think i remember there was a problem with including that library when “searching for inclusions” was selected in the SB settings.
>
> Regards,
> Matthias
>
>
> Matthias Rebbe
>
> free tools for Livecoders:
> https://instamaker.dermattes.de <https://instamaker.dermattes.de/>
> https://winsignhelper.dermattes.de <https://winsignhelper.dermattes.de/>
>> Am 22.10.2018 um 00:45 schrieb Douglas Ruisaard via use-livecode <[hidden email] <mailto:[hidden email]>>:
>>
>> Has anyone recently tried to create a standalone app which includes either a jsonImport or JSONToArray call?
>>
>> While my code works perfectly when run within the LC API, once a standalone is produced, it chokes  on either one of these calls.  I've reduced the code to its bare essentials.  A sample/simple JSON string I am trying is:
>>
>> {
>> "array": [
>>    1,
>>    2,
>>    3
>> ],
>> "boolean": true,
>> "null": null,
>> "number": 123,
>> "object": {
>>    "a": "b",
>>    "c": "d",
>>    "e": "f"
>> },
>> "string": "Hello World"
>> }
>>
>> This string is embedded as a Custom Property within a button.  The button calls the following:
>>
>> on mouseUp
>>
>> // just empty everything to make sure things are in a known state
>>
>>      put empty into temp
>>      put empty into tArray
>>      put empty into dispArray
>>      put empty into tJson
>>
>>      get the json of button "ThingSpeak_Fetch"
>>      put it into testJson
>>
>> // display the JSON before it is converted into an array
>>
>>      answer "Simple JSON example:" & cr & testJson
>>
>> // this line (either "version") will choke the standalone... it doesn't lock it up in the API
>>
>>      put JsonToArray(testJson) into tArray
>>      //put jsonImport(testJson) into tArray
>>
>>      put displayArrayData(tArray,  "") into dispArray
>>      answer dispArray
>>
>> end mouseUp
>>
>> function displayArrayData pArray, pIndent
>>      # create the variable that loops through the keys in the array
>>      local tKey
>>      if pArray is an array then
>>           # print information to indicate that we are entering a new nested level of the array
>>           get "Array" & return
>>           # print full stops that allow the reader to track the depth of an element
>>           put "." after pIndent
>>           # create the indentation
>>           put tab after pIndent
>>           repeat for each key tKey in pArray
>>                # call displayArrayData with a nested array
>>                put format("%s[%s] => %s\n", pIndent, tKey, displayArrayData (pArray[tKey], pIndent)) after it
>>           end repeat
>>           delete the last char of it
>>           return it
>>      else
>>           return pArray
>>      end if
>> end displayArrayData
>>
>> The function call simply outputs the converted array.... and will do so when this code is run from within the API ... but create a Windows standalone and the array output is never generated.
>>
>> I've tried this in Windows 7 Enterprise SP1, LC: 8.1.9, 8.1.10 and 9.0.1 ... also tried on MAC Sierra (10.12.6) and LC 8.1.9
>>
>> All platforms behave identically as described above
>>
>> Any help would be appreciated... meanwhile I'll be submitting this to LC directly
>>
>> Douglas Ruisaard
>> Trilogy Software
>> (250) 573-3935
>>
>>
>>
>>
>> _______________________________________________
>> use-livecode mailing list
>> [hidden email] <mailto:[hidden email]>
>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: jsonImport or JSONToArray

Geoff Canyon via use-livecode


> On 24 Oct 2018, at 10:04 am, Andre Alves Garzia via use-livecode <[hidden email]> wrote:
>
> As you folks may have seen earlier today, I've shipped a new product here on the list. While I was building the demo stack for this plugin, I had the same problem as you describe. In my case it boiled down to the automatic inclusions not working, I ended up needing to do manual inclusions and then it worked.

Yes, we still need to add the inclusions search for many things. I would really like to get rid of the choice of one or the other and just have a button on the inclusions pane to run a search. This would be particularly handy for speeding up builds if we are suddenly looking for many more things!

Cheers

Monte
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: jsonImport or JSONToArray

Geoff Canyon via use-livecode
+1 Great idea!

Bob S

> On Oct 23, 2018, at 16:08 , Monte Goulding via use-livecode <[hidden email]> wrote:
>
>> On 24 Oct 2018, at 10:04 am, Andre Alves Garzia via use-livecode <[hidden email]> wrote:
>>
>> As you folks may have seen earlier today, I've shipped a new product here on the list. While I was building the demo stack for this plugin, I had the same problem as you describe. In my case it boiled down to the automatic inclusions not working, I ended up needing to do manual inclusions and then it worked.
>
> Yes, we still need to add the inclusions search for many things. I would really like to get rid of the choice of one or the other and just have a button on the inclusions pane to run a search. This would be particularly handy for speeding up builds if we are suddenly looking for many more things!
>
> Cheers
>
> Monte


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: jsonImport or JSONToArray

Geoff Canyon via use-livecode
In reply to this post by Geoff Canyon via use-livecode
I'll drink to THAT!! .. but then again, I'll drink to almost anything! ... coffee... what were you thinking?

but seriously, it's a fine idea... particularly as I got blind-sided by finding an irrelevant inclusion (JSON Library) when I needed the mergJSON one.... and the inclusions are NOT even in alphabetical order.

Douglas Ruisaard
Trilogy Software
(250) 573-3935

 

>
>
> > On 24 Oct 2018, at 10:04 am, Andre Alves Garzia via use-livecode <[hidden email]>
> wrote:
> >
> > As you folks may have seen earlier today, I've shipped a new product here on the list. While I was
> building the demo stack for this plugin, I had the same problem as you describe. In my case it boiled
> down to the automatic inclusions not working, I ended up needing to do manual inclusions and then it
> worked.
>
> Yes, we still need to add the inclusions search for many things. I would really like to get rid of the
> choice of one or the other and just have a button on the inclusions pane to run a search. This would
> be particularly handy for speeding up builds if we are suddenly looking for many more things!
>
> Cheers
>
> Monte
>


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