jsonImport or JSONToArray

Douglas Ruisaard dougr at telus.net
Mon Oct 22 11:37:00 EDT 2018


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:dougr at telus.net]
> Sent: Monday, October 22, 2018 8:17 AM
> To: 'use-livecode at lists.runrev.com'
> 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
> > > <use-livecode at lists.runrev.com
> > <mailto:use-livecode at lists.runrev.com>>:
> > >
> > > 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
> > > use-livecode at lists.runrev.com <mailto:use-livecode at lists.runrev.com>
> > > Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> > > http://lists.runrev.com/mailman/listinfo/use-livecode
> >





More information about the use-livecode mailing list