Re: [WebDNA] JSONStore Levels

This WebDNA talk-list message is from

2020


It keeps the original formatting.
numero = 115100
interpreted = N
texte = 2729 --Apple-Mail=_D4F8330C-C544-4260-8B71-B4FD153AFAC9 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Thanks Chris, Nice bit of work/idea. It=E2=80=99s important that we are able to sort = the database in the same order that the data is listed in an array. = Looks like your solution would make that possible. However, I am in = agreement with Tom that if we can get as close as possible to dot = notation or at least mimic the levels or named parameters of the = XMLParse context, that would be optimal. =20 While working around the JSONStore shortcomings, I ran into multiple = stoppers/bugs that I=E2=80=99ve added to a test suite page here: http://jambay.com/jsonstore.dna Mike Davis > On May 6, 2020, at 6:30 AM, talk@webdna.us wrote: >=20 > Chris, >=20 > Hi - this would be great. Just two things to note: >=20 > Will the code work for nested arrays? > Will it allow for JSON that has colons - or any character - in the = node names? >=20 > My view would be that the closer the WebDNA behaviour matches the = behaviour of Javscript the better. >=20 > So looking at this: > = https://stackoverflow.com/questions/2577172/how-to-get-json-objects-value-= if-its-name-contains-dots = >=20 > For the following JSON; >=20 > var mydata =3D =20 > {"list": =20 > [ =20 > {"points.bean.pointsBase": =20 > [ =20 > {"time": 2000, "caption":"caption text", duration: 5000}, =20 > {"time": 6000, "caption":"caption text", duration: 3000} =20 > ] =20 > } =20 > ] =20 > } >=20 > The time value in the first item of the array is extracted using: >=20 > var smth =3D mydata.list[0]["points.bean.pointsBase"][0].time; >=20 > I realise square brackets have special significance in WebDNA, but you = get the idea. >=20 > - Tom >=20 >=20 >=20 > On Wed, 6 May 2020 at 08:24, > = wrote: > Hello everyone! >=20 >=20 > With Josh (who is behind all the C++ code these last years), we spent = some time thinking about this. He made a proof of concept C++ app that = gives the below output when we feed it the JSON from Mike's post to the = mailing list. Is this useful? If this is acceptable, we can adapt the = code into the WebDNA source tree and have it store in the DB/table in = that format. >=20 > page=3D1 > total_results=3D21 > total_pages=3D1 > results:1:popularity=3D1.936 > results:1:vote_count=3D7 > results:2:popularity=3D2.732 > results:2:vote_count=3D23 > results:3:popularity=3D12.088 > results:3:vote_count=3D75 > results:4:popularity=3D53.221 > results:4:vote_count=3D5 > results:5:popularity=3D7.001 > results:5:vote_count=3D31 > results:6:popularity=3D22.223 > results:6:vote_count=3D88 >=20 > Next version would have this fix built-in. >=20 > - chris >=20 >=20 > > On May 1, 2020, at 06:03, talk@webdna.us = wrote: > >=20 > > Hi Mike. > >=20 > > Ah yes, I can see why you need to do it natively. > >=20 > > Sorry, I am out of silver bullets now :( > >=20 > >=20 > > Kind regards > >=20 > > Stuart Tremain > > Pharoah Lane Software > > AUSTRALIA > > webdna@plsoftware.com.au > >=20 > >=20 > >=20 > >=20 > >=20 > >=20 > >=20 > >> On 1 May 2020, at 12:52, talk@webdna.us = wrote: > >>=20 > >> Stuart, > >>=20 > >> I actually use this (Tom=E2=80=99s routine) as the basis of what = I=E2=80=99m doing now. The challenge I=E2=80=99m facing in my current = project is that the source JSON is quite large, and the specific data I = need is near the end of the data, nested in several layers of arrays. = The parsing time is around 90 seconds. I need to speed that up. > >>=20 > >>=20 > >> Mike Davis > >>=20 > >>> On Apr 30, 2020, at 5:04 PM, talk@webdna.us = wrote: > >>>=20 > >>> I am not sure if this is exactly what Tom wrote, but it is what I = am using. > >>>=20 > >>>=20 > >>> [!]------------------- Pass json as JSONRESULT ----------------- > >>> ------------------- Conversion table to strip non-breaking spaces = ----------------- > >>> [/!][TABLE name=3DjsonClean&fields=3Dfrom,to] > >>> %C2=20 > >>> %A0=20 > >>> [/TABLE][!] > >>>=20 > >>> ------------------- Conversion table to facilitate spliting into = key:value pairs ----------------- > >>> [/!][TABLE name=3DjsonSplitConversions&fields=3Dfrom,to] > >>> | ~~~~ > >>> \" ^^^^ > >>> [/TABLE][!] > >>>=20 > >>> ------------------- Convert back after spliting into key:value = pairs ----------------- > >>> [/!][TABLE name=3DjsonSplitConversionsBack&fields=3Dfrom,to] > >>> " =20 > >>> ~~~~ | > >>> ^^^^ " > >>> [/TABLE][!] > >>>=20 > >>> ------------------- pass one - run the conversions = ----------------- > >>> [/!][TEXT]JSONRESULT=3D[CONVERTWORDS = table=3DjsonSplitConversions][convertchars = table=3DjsonClean][JSONRESULT][/convertchars][/CONVERTWORDS][/TEXT][!] > >>>=20 > >>> ------------------- pass two - add bar to just before each = key:value pair ----------------- > >>> [/!][TEXT]JSONRESULT=3D[GREP = search=3D("[^"]*"):&replace=3D|\1=3D][JSONRESULT][/GREP][/TEXT][!] > >>>=20 > >>> ------------------- pass three - list out the key:value pairs and = assign them to text variables ----------------- > >>> [/!][LISTWORDS words=3D[url][JSONRESULT][/url]&delimiters=3D|{}][!] > >>> [/!][TEXT]THISVAL=3D[GREP search=3D(,$)&replace=3D][GETCHARS = start=3D1&trim=3Dboth][CONVERTWORDS = table=3DjsonSplitConversionsBack][word][/CONVERTWORDS][/GETCHARS][/GREP][/= TEXT][!] > >>> [/!][HIDEIF [url][THISVAL][/url]=3D][!] > >>> [/!][TEXT]JSON-[THISVAL][/TEXT][!] > >>> [/!][/HIDEIF][!] > >>> [/!][/LISTWORDS] > >>>=20 > >>>=20 > >>>=20 > >>>=20 > >>>=20 > >>> Kind regards > >>>=20 > >>> Stuart Tremain > >>> Pharoah Lane Software > >>> AUSTRALIA > >>> webdna@plsoftware.com.au > >>>=20 > >>>=20 > >>>=20 > >>>=20 > >>>=20 > >>>=20 > >>>=20 > >>>> On 1 May 2020, at 08:10, talk@webdna.us = wrote: > >>>>=20 > >>>> Hi Stuart, > >>>>=20 > >>>> I appreciate your answer and have a similar kludge (creative = solution) for my application. I was actually hoping to hear from Chris = on this, in hopes that the underlying JSON parser he is using can be = passed dot notation in a similar way that Javascript uses to parse JSON = objects. > >>>>=20 > >>>> Chris, are there any parameters we can send that are not in the = documentation? > >>>>=20 > >>>>=20 > >>>>=20 > >>>> Thanks, > >>>> Mike Davis > >>>>=20 > >>>>> On Apr 22, 2020, at 5:05 PM, talk@webdna.us = wrote: > >>>>>=20 > >>>>> Hi MD > >>>>>=20 > >>>>> As we don=E2=80=99t know the email address of the sender anymore = it would be nice for us to know who we are addressing. > >>>>>=20 > >>>>> The JSONStore tag is a little confusing and what is also not = well documented is that you can store the data in a table eg: > >>>>>=20 > >>>>>=20 > >>>>> [JSONstore table=3DTRANSACTION&fields=3Derror:type,error:message] > >>>>> [STRIPERESPONSE] > >>>>> [/JSONstore] > >>>>>=20 > >>>>> Then search the table: > >>>>>=20 > >>>>> [SEARCH table=3DTRANSACTION&neERROR:TYPEdatarq=3D[BLANK]][!] > >>>>> [/!][FOUNDITEMS][!] > >>>>> [/!][TEXT]ERROR-TYPE=3D[ERROR:TYPE][/TEXT][!] > >>>>> [/!][TEXT]ERROR-MESSAGE=3D[ERROR:MESSAGE][/TEXT][!] > >>>>> [/!][/FOUNDITEMS][!] > >>>>> [/!][/SEARCH] > >>>>>=20 > >>>>>=20 > >>>>> What I found to be a useful exercise was to write to my = specified db and then open it and read the data to see what is being = done with it. JSONsStore will write the headers in a db > >>>>>=20 > >>>>> [JSONstore db=3Dlogs/stripelog.db] > >>>>> [STRIPERESPONSE] > >>>>> [/JSONstore] > >>>>>=20 > >>>>> As the data is often stored in an array you will have to do a = bit of manipulation on the found items. > >>>>>=20 > >>>>> Here is a JSON function that may be useful to you. > >>>>>=20 > >>>>>=20 > >>>>> = [!]---------------------------------------------------------------------- > >>>>> FUNCTION Name: WC-JSONvalue > >>>>> + Description: Pull out a value from a JSONobject > >>>>> + Input:=20 > >>>>> JSONobject =3D (the json to be parsed) - required > >>>>> JSONnode =3D (the node that we want the value of) - = required > >>>>> + usage: [WC-JSONvalue = JSONobject=3D[url][/url]&JSONnode=3D] > >>>>> +Note: This function MUST receive valid JSONobject, make sure = that there are no line breaks before beginning of JSON, test your JSON = validity here: https://jsonlint.com > >>>>> = ---------------------------------------------------------------------- > >>>>> [/!][function name=3DWC-JSONvalue][!] > >>>>> [/!][text]rRETURN=3D[/text][!] > >>>>> [/!][text]rJSONobject=3D[/text][!] > >>>>> [/!][text]rJSONnode=3Dnull[/text][!] > >>>>> [/!][showif = [url][params_string][/url]^JSONobject][text]rJSONobject=3D[JSONobject][/te= xt][/showif][!] > >>>>> [/!][showif = [url][params_string][/url]^JSONnode][text]rJSONnode=3D[JSONnode][/text][/s= howif][!] > >>>>> -------------------- Store the JSONobject in a table = -------------------- > >>>>> [/!][JSONstore table=3DJSONdata][rJSONobject][/jsonstore][!] > >>>>> -------------------- Search the table -------------------- > >>>>> [/!][SEARCH table=3DJSONdata&ne[rJSONnode]data=3Dfind_all][!] > >>>>> [/!][founditems][!] > >>>>> = [/!][text]rRETURN=3D[interpret][[rJSONnode]][/interpret][/text][!] > >>>>> [/!][/founditems][!] > >>>>> [/!][/SEARCH][!] > >>>>> -------------------- Return the value -------------------- > >>>>> [/!][return][rRETURN][/return][!] > >>>>> [/!][/function] > >>>>>=20 > >>>>> You man need to play around with the json object to ensure that = it is valid json, I found that PayPal json did not validate. > >>>>>=20 > >>>>>=20 > >>>>>=20 > >>>>>=20 > >>>>> Kind regards > >>>>>=20 > >>>>> Stuart Tremain > >>>>> Pharoah Lane Software > >>>>> AUSTRALIA > >>>>> webdna@plsoftware.com.au > >>>>>=20 > >>>>>=20 > >>>>>=20 > >>>>>=20 > >>>>>=20 > >>>>>=20 > >>>>>=20 > >>>>>> On 23 Apr 2020, at 06:45, talk@webdna.us = wrote: > >>>>>>=20 > >>>>>> Hi all, > >>>>>>=20 > >>>>>> I=E2=80=99m looking at the docs for the JSONStore context. It = seems that either the context is lacking functionality or the = documentation is. I do not see a way to access nested levels in the = JSON, like can be done with XML using path=3D0:1:2 for example. Seems = like there should be a way to use dot notation to get at nested data = without storing each array in a temp db, then reparsing each level with = JSONStore into another temp db, etc. > >>>>>>=20 > >>>>>> For example: I want to iterate the data sets in the = =E2=80=9Cresults=E2=80=9D array into a database. I can use JSONStore to = populate a table with the fields: page, total_results, total_pages and = results. Then I can search that table and run JSONStore on the results = field using another database, but this gets a bit complicated when = working with some other data, in which I need to access data that is 3 = or 4 arrays deep. > >>>>>>=20 > >>>>>> Anyone solved this puzzle in a more efficient way yet? > >>>>>>=20 > >>>>>> { > >>>>>> "page":1, > >>>>>> "total_results":21, > >>>>>> "total_pages":1, > >>>>>> "results=E2=80=9D:[ > >>>>>> { > >>>>>> "popularity":1.936,"vote_count=E2=80=9D:7 > >>>>>> }, > >>>>>> { > >>>>>> "popularity=E2=80=9D:2.732,"vote_count=E2=80=9D:23 > >>>>>> }, > >>>>>> { > >>>>>> "popularity=E2=80=9D:12.088,"vote_count=E2=80=9D:75 > >>>>>> }, > >>>>>> { > >>>>>> "popularity=E2=80=9D:53.221,"vote_count=E2=80=9D:5 > >>>>>> }, > >>>>>> { > >>>>>> "popularity=E2=80=9D:7.001,"vote_count=E2=80=9D:31 > >>>>>> }, > >>>>>> { > >>>>>> "popularity=E2=80=9D:22.223,"vote_count=E2=80=9D:88 > >>>>>> } > >>>>>> ] > >>>>>> } > >>>>>>=20 > >>>>>>=20 > >>>>>>=20 > >>>>>>=20 > >>>>>> MD--------------------------------------------------------- > >>>>>> This message is sent to you because you are subscribed to > >>>>>> the mailing list talk@webdna.us > >>>>>> To unsubscribe, E-mail to: talk-leave@webdna.us = > >>>>>> archives: http://www.webdna.us/page.dna?numero=3D55 = > >>>>>> Bug Reporting: support@webdna.us > >>>>>=20 > >>>>> --------------------------------------------------------- This = message is sent to you because you are subscribed to the mailing list = talk@webdna.us To unsubscribe, E-mail to: = talk-leave@webdna.us archives: = http://www.webdna.us/page.dna?numero=3D55 = Bug Reporting: = support@webdna.us > >>>>=20 > >>>> --------------------------------------------------------- This = message is sent to you because you are subscribed to the mailing list = talk@webdna.us To unsubscribe, E-mail to: = talk-leave@webdna.us archives: = http://www.webdna.us/page.dna?numero=3D55 = Bug Reporting: = support@webdna.us > >>>=20 > >>> --------------------------------------------------------- This = message is sent to you because you are subscribed to the mailing list = talk@webdna.us To unsubscribe, E-mail to: = talk-leave@webdna.us archives: = http://www.webdna.us/page.dna?numero=3D55 = Bug Reporting: = support@webdna.us > >>=20 > >> --------------------------------------------------------- This = message is sent to you because you are subscribed to the mailing list = talk@webdna.us To unsubscribe, E-mail to: = talk-leave@webdna.us archives: = http://www.webdna.us/page.dna?numero=3D55 = Bug Reporting: = support@webdna.us > >=20 > > --------------------------------------------------------- This = message is sent to you because you are subscribed to the mailing list = talk@webdna.us To unsubscribe, E-mail to: = talk-leave@webdna.us archives: = http://www.webdna.us/page.dna?numero=3D55 = Bug Reporting: = support@webdna.us >=20 > --------------------------------------------------------- > This message is sent to you because you are subscribed to > the mailing list talk@webdna.us > To unsubscribe, E-mail to: talk-leave@webdna.us = > archives: http://www.webdna.us/page.dna?numero=3D55 = > Bug Reporting: support@webdna.us > --------------------------------------------------------- This message = is sent to you because you are subscribed to the mailing list = talk@webdna.us To unsubscribe, E-mail to: talk-leave@webdna.us archives: = http://www.webdna.us/page.dna?numero=3D55 Bug Reporting: = support@webdna.us --Apple-Mail=_D4F8330C-C544-4260-8B71-B4FD153AFAC9 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 Thanks Chris,

Nice bit of work/idea.  It=E2=80=99s important that we = are able to sort the database in the same order that the data is listed = in an array.  Looks like your solution would make that possible. =  However, I am in agreement with Tom that if we can get as close as = possible to dot notation or at least mimic the levels or named = parameters of the XMLParse context, that would be optimal. =  

While = working around the JSONStore shortcomings, I ran into multiple = stoppers/bugs that I=E2=80=99ve added to a test suite page = here:


Mike= Davis

On May 6, 2020, at 6:30 AM, talk@webdna.us = wrote:

Chris,

Hi - this would be great.  Just two things to = note:

  • Will the code work for nested arrays?
  • Will it allow for JSON that has colons - = or any character - in the node names?

My view would be that = the closer the WebDNA behaviour matches the behaviour of Javscript the = better.

So = looking at this:

For the following = JSON;

var mydata =3D =   
{"list": =  
  [ =  
    = {"points.bean.pointsBase": =  
    =   [  
    =     {"time": 2000, "caption":"caption text", duration: 5000}, =  
    =     {"time": 6000, "caption":"caption text", duration: 3000} =  
    =   ]  
    = }  
  ] =  
}

The time value in = the first item of the array is extracted using:

var smth =3D = mydata.list[0]["points.bean.pointsBase"][0].time;
I realise square brackets = have special significance in WebDNA, but you get = the idea.

- = Tom



On Wed, 6 May 2020 at 08:24, <talk@webdna.us> = wrote:
Hello everyone!


With Josh (who is behind all the C++ code these last years), we spent = some time thinking about this. He made a proof of concept C++ app that = gives the below output when we feed it the JSON from Mike's post to the = mailing list. Is this useful? If this is acceptable, we can adapt the = code into the WebDNA source tree and have it store in the DB/table in = that format.

page=3D1
total_results=3D21
total_pages=3D1
results:1:popularity=3D1.936
results:1:vote_count=3D7
results:2:popularity=3D2.732
results:2:vote_count=3D23
results:3:popularity=3D12.088
results:3:vote_count=3D75
results:4:popularity=3D53.221
results:4:vote_count=3D5
results:5:popularity=3D7.001
results:5:vote_count=3D31
results:6:popularity=3D22.223
results:6:vote_count=3D88

Next version would have this fix built-in.

- chris


> On May 1, 2020, at 06:03, talk@webdna.us wrote:
>
> Hi Mike.
>
> Ah yes, I can see why you need to do it natively.
>
> Sorry, I am out of silver bullets now :(
>
>
> Kind regards
>
> Stuart Tremain
> Pharoah Lane Software
> AUSTRALIA
> webdna@plsoftware.com.au
>
>
>
>
>
>
>
>> On 1 May 2020, at 12:52, talk@webdna.us wrote:
>>
>> Stuart,
>>
>> I actually use this (Tom=E2=80=99s routine) as the basis of = what I=E2=80=99m doing now.  The challenge I=E2=80=99m facing in my = current project is that the source JSON is quite large, and the specific = data I need is near the end of the data, nested in several layers of = arrays.  The parsing time is around 90 seconds.  I need to = speed that up.
>>
>>
>> Mike Davis
>>
>>> On Apr 30, 2020, at 5:04 PM, talk@webdna.us wrote:
>>>
>>> I am not sure if this is exactly what Tom wrote, but it is = what I am using.
>>>
>>>
>>> [!]------------------- Pass json as JSONRESULT = -----------------
>>> ------------------- Conversion table to strip non-breaking = spaces -----------------
>>> [/!][TABLE name=3DjsonClean&fields=3Dfrom,to]
>>> %C2
>>> %A0
>>> [/TABLE][!]
>>>
>>> ------------------- Conversion table to facilitate spliting = into key:value pairs -----------------
>>> [/!][TABLE name=3DjsonSplitConversions&fields=3Dfrom,to]<= br class=3D""> >>> |   ~~~~
>>> \"  ^^^^
>>> [/TABLE][!]
>>>
>>> ------------------- Convert back after spliting into = key:value pairs -----------------
>>> [/!][TABLE = name=3DjsonSplitConversionsBack&fields=3Dfrom,to]
>>> "   
>>> ~~~~        |
>>> ^^^^        "
>>> [/TABLE][!]
>>>
>>> ------------------- pass one - run the conversions = -----------------
>>> [/!][TEXT]JSONRESULT=3D[CONVERTWORDS = table=3DjsonSplitConversions][convertchars = table=3DjsonClean][JSONRESULT][/convertchars][/CONVERTWORDS][/TEXT][!]
>>>
>>> ------------------- pass two - add bar to just before each = key:value pair -----------------
>>> [/!][TEXT]JSONRESULT=3D[GREP = search=3D("[^"]*"):&replace=3D|\1=3D][JSONRESULT][/GREP][/TEXT][!]
>>>
>>> ------------------- pass three - list out the key:value = pairs and assign them to text variables -----------------
>>> [/!][LISTWORDS = words=3D[url][JSONRESULT][/url]&delimiters=3D|{}][!]
>>>     [/!][TEXT]THISVAL=3D[GREP = search=3D(,$)&replace=3D][GETCHARS = start=3D1&trim=3Dboth][CONVERTWORDS = table=3DjsonSplitConversionsBack][word][/CONVERTWORDS][/GETCHARS][/GREP][/= TEXT][!]
>>>     [/!][HIDEIF [url][THISVAL][/url]=3D][!] >>>            =  [/!][TEXT]JSON-[THISVAL][/TEXT][!]
>>>     [/!][/HIDEIF][!]
>>> [/!][/LISTWORDS]
>>>
>>>
>>>
>>>
>>>
>>> Kind regards
>>>
>>> Stuart Tremain
>>> Pharoah Lane Software
>>> AUSTRALIA
>>> webdna@plsoftware.com.au
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>> On 1 May 2020, at 08:10, talk@webdna.us wrote:
>>>>
>>>> Hi Stuart,
>>>>
>>>> I appreciate your answer and have a similar kludge = (creative solution) for my application.  I was actually hoping to = hear from Chris on this, in hopes that the underlying JSON parser he is = using can be passed dot notation in a similar way that Javascript uses = to parse JSON objects.
>>>>
>>>> Chris, are there any parameters we can send that are = not in the documentation?
>>>>
>>>>
>>>>
>>>> Thanks,
>>>> Mike Davis
>>>>
>>>>> On Apr 22, 2020, at 5:05 PM, talk@webdna.us wrote:
>>>>>
>>>>> Hi MD
>>>>>
>>>>> As we don=E2=80=99t know the email address of the = sender anymore it would be nice for us to know who we are addressing.
>>>>>
>>>>> The JSONStore tag is a little confusing and what is = also not well documented is that you can store the data in a table = eg:
>>>>>
>>>>>
>>>>> [JSONstore = table=3DTRANSACTION&fields=3Derror:type,error:message]
>>>>> [STRIPERESPONSE]
>>>>> [/JSONstore]
>>>>>
>>>>> Then search the table:
>>>>>
>>>>> [SEARCH = table=3DTRANSACTION&neERROR:TYPEdatarq=3D[BLANK]][!]
>>>>>   [/!][FOUNDITEMS][!]
>>>>>          =  [/!][TEXT]ERROR-TYPE=3D[ERROR:TYPE][/TEXT][!]
>>>>>          =  [/!][TEXT]ERROR-MESSAGE=3D[ERROR:MESSAGE][/TEXT][!]
>>>>>   [/!][/FOUNDITEMS][!]
>>>>> [/!][/SEARCH]
>>>>>
>>>>>
>>>>> What I found to be a useful exercise was to write = to my specified db and then open it and read the data to see what is = being done with it. JSONsStore will write the headers in a db
>>>>>
>>>>> [JSONstore db=3Dlogs/stripelog.db]
>>>>> [STRIPERESPONSE]
>>>>> [/JSONstore]
>>>>>
>>>>> As the data is often stored in an array you will = have to do a bit of manipulation on the found items.
>>>>>
>>>>> Here is a JSON function that may be useful to = you.
>>>>>
>>>>>
>>>>> = [!]----------------------------------------------------------------------<= br class=3D""> >>>>> FUNCTION Name: WC-JSONvalue
>>>>>   + Description: Pull out a value from a = JSONobject
>>>>>   + Input:
>>>>>         JSONobject =3D = (the json to be parsed) - required
>>>>>         JSONnode =3D (the = node that we want the value of) - required
>>>>>   + usage: [WC-JSONvalue = JSONobject=3D[url]<the-json-object>[/url]&JSONnode=3D<the-jso= n-node>]
>>>>>   +Note: This function MUST receive valid = JSONobject, make sure that there are no line breaks before beginning of = JSON, test your JSON validity here: https://jsonlint.com
>>>>> = ----------------------------------------------------------------------
>>>>> [/!][function name=3DWC-JSONvalue][!]
>>>>>   [/!][text]rRETURN=3D[/text][!]
>>>>>   [/!][text]rJSONobject=3D[/text][!]
>>>>>   [/!][text]rJSONnode=3Dnull[/text][!]
>>>>>   [/!][showif = [url][params_string][/url]^JSONobject][text]rJSONobject=3D[JSONobject][/te= xt][/showif][!]
>>>>>   [/!][showif = [url][params_string][/url]^JSONnode][text]rJSONnode=3D[JSONnode][/text][/s= howif][!]
>>>>>   --------------------  Store the = JSONobject in a table  --------------------
>>>>>   [/!][JSONstore = table=3DJSONdata][rJSONobject][/jsonstore][!]
>>>>>   --------------------  Search the = table  --------------------
>>>>>   [/!][SEARCH = table=3DJSONdata&ne[rJSONnode]data=3Dfind_all][!]
>>>>>          =  [/!][founditems][!]
>>>>>              =     =  [/!][text]rRETURN=3D[interpret][[rJSONnode]][/interpret][/text][!] >>>>>          =  [/!][/founditems][!]
>>>>>   [/!][/SEARCH][!]
>>>>>   --------------------  Return the = value  --------------------
>>>>>   [/!][return][rRETURN][/return][!]
>>>>> [/!][/function]
>>>>>
>>>>> You man need to play around with the json object to = ensure that it is valid json, I found that PayPal json did not = validate.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> Kind regards
>>>>>
>>>>> Stuart Tremain
>>>>> Pharoah Lane Software
>>>>> AUSTRALIA
>>>>> webdna@plsoftware.com.au
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>> On 23 Apr 2020, at 06:45, talk@webdna.us wrote:
>>>>>>
>>>>>> Hi all,
>>>>>>
>>>>>> I=E2=80=99m looking at the docs for the = JSONStore context.  It seems that either the context is lacking = functionality or the documentation is.  I do not see a way to = access nested levels in the JSON, like can be done with XML using = path=3D0:1:2 for example.  Seems like there should be a way to use = dot notation to get at nested data without storing each array in a temp = db, then reparsing each level with JSONStore into another temp db, = etc.
>>>>>>
>>>>>> For example:  I want to iterate the data = sets in the =E2=80=9Cresults=E2=80=9D array into a database.  I can = use JSONStore to populate a table with the fields: page, total_results, = total_pages and results.   Then I can search that table and = run JSONStore on the results field using another database, but this gets = a bit complicated when working with some other data, in which I need to = access data that is 3 or 4 arrays deep.
>>>>>>
>>>>>> Anyone solved this puzzle in a more efficient = way yet?
>>>>>>
>>>>>> {
>>>>>>    "page":1,
>>>>>>    "total_results":21,
>>>>>>    "total_pages":1,
>>>>>>    "results=E2=80=9D:[
>>>>>>        {
>>>>>>            = "popularity":1.936,"vote_count=E2=80=9D:7
>>>>>>        },
>>>>>>        {
>>>>>>            = "popularity=E2=80=9D:2.732,"vote_count=E2=80=9D:23
>>>>>>        },
>>>>>>        {
>>>>>>            = "popularity=E2=80=9D:12.088,"vote_count=E2=80=9D:75
>>>>>>        },
>>>>>>        {
>>>>>>            = "popularity=E2=80=9D:53.221,"vote_count=E2=80=9D:5
>>>>>>        },
>>>>>>        {
>>>>>>            = "popularity=E2=80=9D:7.001,"vote_count=E2=80=9D:31
>>>>>>        },
>>>>>>        {
>>>>>>            = "popularity=E2=80=9D:22.223,"vote_count=E2=80=9D:88
>>>>>>        }
>>>>>>    ]
>>>>>> }
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> = MD---------------------------------------------------------
= >>>>>> This message is sent to you because you are = subscribed to
>>>>>> the mailing list talk@webdna.us
>>>>>> To unsubscribe, E-mail to: talk-leave@webdna.us
>>>>>> archives: http://www.webdna.us/page.dna?numero=3D55
>>>>>> Bug Reporting: support@webdna.us
>>>>>
>>>>> = --------------------------------------------------------- This message = is sent to you because you are subscribed to the mailing list talk@webdna.us To unsubscribe, E-mail to: talk-leave@webdna.us archives: http://www.webdna.us/page.dna?numero=3D55= Bug Reporting: support@webdna.us
>>>>
>>>> = --------------------------------------------------------- This message = is sent to you because you are subscribed to the mailing list talk@webdna.us To unsubscribe, E-mail to: talk-leave@webdna.us archives: http://www.webdna.us/page.dna?numero=3D55= Bug Reporting: support@webdna.us
>>>
>>> --------------------------------------------------------- = This message is sent to you because you are subscribed to the mailing = list talk@webdna.us To unsubscribe, E-mail to: talk-leave@webdna.us archives: http://www.webdna.us/page.dna?numero=3D55= Bug Reporting: support@webdna.us
>>
>> --------------------------------------------------------- This = message is sent to you because you are subscribed to the mailing list talk@webdna.us To unsubscribe, E-mail to: talk-leave@webdna.us archives: http://www.webdna.us/page.dna?numero=3D55= Bug Reporting: support@webdna.us
>
> --------------------------------------------------------- This = message is sent to you because you are subscribed to the mailing list talk@webdna.us To unsubscribe, E-mail to: talk-leave@webdna.us archives: http://www.webdna.us/page.dna?numero=3D55= Bug Reporting: support@webdna.us

---------------------------------------------------------
This message is sent to you because you are subscribed to
the mailing list talk@webdna.us
To unsubscribe, E-mail to: talk-leave@webdna.us
archives: http://www.webdna.us/page.dna?numero=3D55
Bug Reporting: support@webdna.us
--------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list talk@webdna.us To unsubscribe, E-mail to: talk-leave@webdna.us archives: http://www.webdna.us/page.dna?numero=3D55 Bug Reporting: support@webdna.us

= --------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list talk@webdna.us To unsubscribe, E-mail to: talk-leave@webdna.us archives: http://www.webdna.us/page.dna?numero=3D55 Bug Reporting: support@webdna.us --Apple-Mail=_D4F8330C-C544-4260-8B71-B4FD153AFAC9-- . Associated Messages, from the most recent to the oldest:

    
  1. Re: [WebDNA] JSONStore Levels (Stuart Tremain 2020)
  2. Re: [WebDNA] JSONStore Levels (Tom Duke 2020)
  3. Re: [WebDNA] JSONStore Levels (christophe.billiottet@webdna.us 2020)
  4. Re: [WebDNA] JSONStore Levels (Tom Duke 2020)
  5. Re: [WebDNA] JSONStore Levels (christophe.billiottet@webdna.us 2020)
  6. Re: [WebDNA] JSONStore Levels (christophe.billiottet@webdna.us 2020)
  7. Re: [WebDNA] JSONStore Levels (Michael Davis 2020)
  8. Re: [WebDNA] JSONStore Levels (Tom Duke 2020)
  9. Re: [WebDNA] JSONStore Levels (Michael Davis 2020)
  10. Re: [WebDNA] JSONStore Levels (Tom Duke 2020)
  11. Re: [WebDNA] JSONStore Levels (Stuart Tremain 2020)
  12. Re: [WebDNA] JSONStore Levels (christophe.billiottet@webdna.us 2020)
  13. RE: [WebDNA] JSONStore Levels ("Scott @ Itsula" 2020)
  14. Re: [WebDNA] JSONStore Levels (Stuart Tremain 2020)
  15. Re: [WebDNA] JSONStore Levels (Michael Davis 2020)
  16. Re: [WebDNA] JSONStore Levels (Stuart Tremain 2020)
  17. Re: [WebDNA] JSONStore Levels (Stuart Tremain 2020)
  18. Re: [WebDNA] JSONStore Levels (Michael Davis 2020)
  19. Re: [WebDNA] JSONStore Levels (Stuart Tremain 2020)
  20. [WebDNA] JSONStore Levels (Michael Davis 2020)
2729 --Apple-Mail=_D4F8330C-C544-4260-8B71-B4FD153AFAC9 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Thanks Chris, Nice bit of work/idea. It=E2=80=99s important that we are able to sort = the database in the same order that the data is listed in an array. = Looks like your solution would make that possible. However, I am in = agreement with Tom that if we can get as close as possible to dot = notation or at least mimic the levels or named parameters of the = XMLParse context, that would be optimal. =20 While working around the JSONStore shortcomings, I ran into multiple = stoppers/bugs that I=E2=80=99ve added to a test suite page here: http://jambay.com/jsonstore.dna Mike Davis > On May 6, 2020, at 6:30 AM, talk@webdna.us wrote: >=20 > Chris, >=20 > Hi - this would be great. Just two things to note: >=20 > Will the code work for nested arrays? > Will it allow for JSON that has colons - or any character - in the = node names? >=20 > My view would be that the closer the WebDNA behaviour matches the = behaviour of Javscript the better. >=20 > So looking at this: > = https://stackoverflow.com/questions/2577172/how-to-get-json-objects-value-= if-its-name-contains-dots = >=20 > For the following JSON; >=20 > var mydata =3D =20 > {"list": =20 > [ =20 > {"points.bean.pointsBase": =20 > [ =20 > {"time": 2000, "caption":"caption text", duration: 5000}, =20 > {"time": 6000, "caption":"caption text", duration: 3000} =20 > ] =20 > } =20 > ] =20 > } >=20 > The time value in the first item of the array is extracted using: >=20 > var smth =3D mydata.list[0]["points.bean.pointsBase"][0].time; >=20 > I realise square brackets have special significance in WebDNA, but you = get the idea. >=20 > - Tom >=20 >=20 >=20 > On Wed, 6 May 2020 at 08:24, > = wrote: > Hello everyone! >=20 >=20 > With Josh (who is behind all the C++ code these last years), we spent = some time thinking about this. He made a proof of concept C++ app that = gives the below output when we feed it the JSON from Mike's post to the = mailing list. Is this useful? If this is acceptable, we can adapt the = code into the WebDNA source tree and have it store in the DB/table in = that format. >=20 > page=3D1 > total_results=3D21 > total_pages=3D1 > results:1:popularity=3D1.936 > results:1:vote_count=3D7 > results:2:popularity=3D2.732 > results:2:vote_count=3D23 > results:3:popularity=3D12.088 > results:3:vote_count=3D75 > results:4:popularity=3D53.221 > results:4:vote_count=3D5 > results:5:popularity=3D7.001 > results:5:vote_count=3D31 > results:6:popularity=3D22.223 > results:6:vote_count=3D88 >=20 > Next version would have this fix built-in. >=20 > - chris >=20 >=20 > > On May 1, 2020, at 06:03, talk@webdna.us = wrote: > >=20 > > Hi Mike. > >=20 > > Ah yes, I can see why you need to do it natively. > >=20 > > Sorry, I am out of silver bullets now :( > >=20 > >=20 > > Kind regards > >=20 > > Stuart Tremain > > Pharoah Lane Software > > AUSTRALIA > > webdna@plsoftware.com.au > >=20 > >=20 > >=20 > >=20 > >=20 > >=20 > >=20 > >> On 1 May 2020, at 12:52, talk@webdna.us = wrote: > >>=20 > >> Stuart, > >>=20 > >> I actually use this (Tom=E2=80=99s routine) as the basis of what = I=E2=80=99m doing now. The challenge I=E2=80=99m facing in my current = project is that the source JSON is quite large, and the specific data I = need is near the end of the data, nested in several layers of arrays. = The parsing time is around 90 seconds. I need to speed that up. > >>=20 > >>=20 > >> Mike Davis > >>=20 > >>> On Apr 30, 2020, at 5:04 PM, talk@webdna.us = wrote: > >>>=20 > >>> I am not sure if this is exactly what Tom wrote, but it is what I = am using. > >>>=20 > >>>=20 > >>> [!]------------------- Pass json as JSONRESULT ----------------- > >>> ------------------- Conversion table to strip non-breaking spaces = ----------------- > >>> [/!][TABLE name=3DjsonClean&fields=3Dfrom,to] > >>> %C2=20 > >>> %A0=20 > >>> [/TABLE][!] > >>>=20 > >>> ------------------- Conversion table to facilitate spliting into = key:value pairs ----------------- > >>> [/!][TABLE name=3DjsonSplitConversions&fields=3Dfrom,to] > >>> | ~~~~ > >>> \" ^^^^ > >>> [/TABLE][!] > >>>=20 > >>> ------------------- Convert back after spliting into key:value = pairs ----------------- > >>> [/!][TABLE name=3DjsonSplitConversionsBack&fields=3Dfrom,to] > >>> " =20 > >>> ~~~~ | > >>> ^^^^ " > >>> [/TABLE][!] > >>>=20 > >>> ------------------- pass one - run the conversions = ----------------- > >>> [/!][text]JSONRESULT=3D[CONVERTWORDS = table=3DjsonSplitConversions][convertchars = table=3DjsonClean][JSONRESULT][/convertchars][/CONVERTWORDS][/TEXT][!] > >>>=20 > >>> ------------------- pass two - add bar to just before each = key:value pair ----------------- > >>> [/!][text]JSONRESULT=3D[GREP = search=3D("[^"]*"):&replace=3D|\1=3D][JSONRESULT][/GREP][/TEXT][!] > >>>=20 > >>> ------------------- pass three - list out the key:value pairs and = assign them to text variables ----------------- > >>> [/!][LISTWORDS words=3D[url][JSONRESULT][/url]&delimiters=3D|{}][!] > >>> [/!][text]THISVAL=3D[GREP search=3D(,$)&replace=3D][GETCHARS = start=3D1&trim=3Dboth][CONVERTWORDS = table=3DjsonSplitConversionsBack][word][/CONVERTWORDS][/GETCHARS][/GREP][/= TEXT][!] > >>> [/!][HIDEIF [url][THISVAL][/url]=3D][!] > >>> [/!][text]JSON-[THISVAL][/TEXT][!] > >>> [/!][/HIDEIF][!] > >>> [/!][/LISTWORDS] > >>>=20 > >>>=20 > >>>=20 > >>>=20 > >>>=20 > >>> Kind regards > >>>=20 > >>> Stuart Tremain > >>> Pharoah Lane Software > >>> AUSTRALIA > >>> webdna@plsoftware.com.au > >>>=20 > >>>=20 > >>>=20 > >>>=20 > >>>=20 > >>>=20 > >>>=20 > >>>> On 1 May 2020, at 08:10, talk@webdna.us = wrote: > >>>>=20 > >>>> Hi Stuart, > >>>>=20 > >>>> I appreciate your answer and have a similar kludge (creative = solution) for my application. I was actually hoping to hear from Chris = on this, in hopes that the underlying JSON parser he is using can be = passed dot notation in a similar way that Javascript uses to parse JSON = objects. > >>>>=20 > >>>> Chris, are there any parameters we can send that are not in the = documentation? > >>>>=20 > >>>>=20 > >>>>=20 > >>>> Thanks, > >>>> Mike Davis > >>>>=20 > >>>>> On Apr 22, 2020, at 5:05 PM, talk@webdna.us = wrote: > >>>>>=20 > >>>>> Hi MD > >>>>>=20 > >>>>> As we don=E2=80=99t know the email address of the sender anymore = it would be nice for us to know who we are addressing. > >>>>>=20 > >>>>> The JSONStore tag is a little confusing and what is also not = well documented is that you can store the data in a table eg: > >>>>>=20 > >>>>>=20 > >>>>> [JSONstore table=3DTRANSACTION&fields=3Derror:type,error:message] > >>>>> [STRIPERESPONSE] > >>>>> [/JSONstore] > >>>>>=20 > >>>>> Then search the table: > >>>>>=20 > >>>>> [SEARCH table=3DTRANSACTION&neERROR:TYPEdatarq=3D[BLANK]][!] > >>>>> [/!][founditems][!] > >>>>> [/!][text]ERROR-TYPE=3D[ERROR:TYPE][/TEXT][!] > >>>>> [/!][text]ERROR-MESSAGE=3D[ERROR:MESSAGE][/TEXT][!] > >>>>> [/!][/FOUNDITEMS][!] > >>>>> [/!][/SEARCH] > >>>>>=20 > >>>>>=20 > >>>>> What I found to be a useful exercise was to write to my = specified db and then open it and read the data to see what is being = done with it. JSONsStore will write the headers in a db > >>>>>=20 > >>>>> [JSONstore db=3Dlogs/stripelog.db] > >>>>> [STRIPERESPONSE] > >>>>> [/JSONstore] > >>>>>=20 > >>>>> As the data is often stored in an array you will have to do a = bit of manipulation on the found items. > >>>>>=20 > >>>>> Here is a JSON function that may be useful to you. > >>>>>=20 > >>>>>=20 > >>>>> = [!]---------------------------------------------------------------------- > >>>>> FUNCTION Name: WC-JSONvalue > >>>>> + Description: Pull out a value from a JSONobject > >>>>> + Input:=20 > >>>>> JSONobject =3D (the json to be parsed) - required > >>>>> JSONnode =3D (the node that we want the value of) - = required > >>>>> + usage: [WC-JSONvalue = JSONobject=3D[url][/url]&JSONnode=3D] > >>>>> +Note: This function MUST receive valid JSONobject, make sure = that there are no line breaks before beginning of JSON, test your JSON = validity here: https://jsonlint.com > >>>>> = ---------------------------------------------------------------------- > >>>>> [/!][function name=3DWC-JSONvalue][!] > >>>>> [/!][text]rRETURN=3D[/text][!] > >>>>> [/!][text]rJSONobject=3D[/text][!] > >>>>> [/!][text]rJSONnode=3Dnull[/text][!] > >>>>> [/!][showif = [url][params_string][/url]^JSONobject][text]rJSONobject=3D[JSONobject][/te= xt][/showif][!] > >>>>> [/!][showif = [url][params_string][/url]^JSONnode][text]rJSONnode=3D[JSONnode][/text][/s= howif][!] > >>>>> -------------------- Store the JSONobject in a table = -------------------- > >>>>> [/!][JSONstore table=3DJSONdata][rJSONobject][/jsonstore][!] > >>>>> -------------------- Search the table -------------------- > >>>>> [/!][SEARCH table=3DJSONdata&ne[rJSONnode]data=3Dfind_all][!] > >>>>> [/!][founditems][!] > >>>>> = [/!][text]rRETURN=3D[interpret][[rJSONnode]][/interpret][/text][!] > >>>>> [/!][/founditems][!] > >>>>> [/!][/SEARCH][!] > >>>>> -------------------- Return the value -------------------- > >>>>> [/!][return][rRETURN][/return][!] > >>>>> [/!][/function] > >>>>>=20 > >>>>> You man need to play around with the json object to ensure that = it is valid json, I found that PayPal json did not validate. > >>>>>=20 > >>>>>=20 > >>>>>=20 > >>>>>=20 > >>>>> Kind regards > >>>>>=20 > >>>>> Stuart Tremain > >>>>> Pharoah Lane Software > >>>>> AUSTRALIA > >>>>> webdna@plsoftware.com.au > >>>>>=20 > >>>>>=20 > >>>>>=20 > >>>>>=20 > >>>>>=20 > >>>>>=20 > >>>>>=20 > >>>>>> On 23 Apr 2020, at 06:45, talk@webdna.us = wrote: > >>>>>>=20 > >>>>>> Hi all, > >>>>>>=20 > >>>>>> I=E2=80=99m looking at the docs for the JSONStore context. It = seems that either the context is lacking functionality or the = documentation is. I do not see a way to access nested levels in the = JSON, like can be done with XML using path=3D0:1:2 for example. Seems = like there should be a way to use dot notation to get at nested data = without storing each array in a temp db, then reparsing each level with = JSONStore into another temp db, etc. > >>>>>>=20 > >>>>>> For example: I want to iterate the data sets in the = =E2=80=9Cresults=E2=80=9D array into a database. I can use JSONStore to = populate a table with the fields: page, total_results, total_pages and = results. Then I can search that table and run JSONStore on the results = field using another database, but this gets a bit complicated when = working with some other data, in which I need to access data that is 3 = or 4 arrays deep. > >>>>>>=20 > >>>>>> Anyone solved this puzzle in a more efficient way yet? > >>>>>>=20 > >>>>>> { > >>>>>> "page":1, > >>>>>> "total_results":21, > >>>>>> "total_pages":1, > >>>>>> "results=E2=80=9D:[ > >>>>>> { > >>>>>> "popularity":1.936,"vote_count=E2=80=9D:7 > >>>>>> }, > >>>>>> { > >>>>>> "popularity=E2=80=9D:2.732,"vote_count=E2=80=9D:23 > >>>>>> }, > >>>>>> { > >>>>>> "popularity=E2=80=9D:12.088,"vote_count=E2=80=9D:75 > >>>>>> }, > >>>>>> { > >>>>>> "popularity=E2=80=9D:53.221,"vote_count=E2=80=9D:5 > >>>>>> }, > >>>>>> { > >>>>>> "popularity=E2=80=9D:7.001,"vote_count=E2=80=9D:31 > >>>>>> }, > >>>>>> { > >>>>>> "popularity=E2=80=9D:22.223,"vote_count=E2=80=9D:88 > >>>>>> } > >>>>>> ] > >>>>>> } > >>>>>>=20 > >>>>>>=20 > >>>>>>=20 > >>>>>>=20 > >>>>>> MD--------------------------------------------------------- > >>>>>> This message is sent to you because you are subscribed to > >>>>>> the mailing list talk@webdna.us > >>>>>> To unsubscribe, E-mail to: talk-leave@webdna.us = > >>>>>> archives: http://www.webdna.us/page.dna?numero=3D55 = > >>>>>> Bug Reporting: support@webdna.us > >>>>>=20 > >>>>> --------------------------------------------------------- This = message is sent to you because you are subscribed to the mailing list = talk@webdna.us To unsubscribe, E-mail to: = talk-leave@webdna.us archives: = http://www.webdna.us/page.dna?numero=3D55 = Bug Reporting: = support@webdna.us > >>>>=20 > >>>> --------------------------------------------------------- This = message is sent to you because you are subscribed to the mailing list = talk@webdna.us To unsubscribe, E-mail to: = talk-leave@webdna.us archives: = http://www.webdna.us/page.dna?numero=3D55 = Bug Reporting: = support@webdna.us > >>>=20 > >>> --------------------------------------------------------- This = message is sent to you because you are subscribed to the mailing list = talk@webdna.us To unsubscribe, E-mail to: = talk-leave@webdna.us archives: = http://www.webdna.us/page.dna?numero=3D55 = Bug Reporting: = support@webdna.us > >>=20 > >> --------------------------------------------------------- This = message is sent to you because you are subscribed to the mailing list = talk@webdna.us To unsubscribe, E-mail to: = talk-leave@webdna.us archives: = http://www.webdna.us/page.dna?numero=3D55 = Bug Reporting: = support@webdna.us > >=20 > > --------------------------------------------------------- This = message is sent to you because you are subscribed to the mailing list = talk@webdna.us To unsubscribe, E-mail to: = talk-leave@webdna.us archives: = http://www.webdna.us/page.dna?numero=3D55 = Bug Reporting: = support@webdna.us >=20 > --------------------------------------------------------- > This message is sent to you because you are subscribed to > the mailing list talk@webdna.us > To unsubscribe, E-mail to: talk-leave@webdna.us = > archives: http://www.webdna.us/page.dna?numero=3D55 = > Bug Reporting: support@webdna.us > --------------------------------------------------------- This message = is sent to you because you are subscribed to the mailing list = talk@webdna.us To unsubscribe, E-mail to: talk-leave@webdna.us archives: = http://www.webdna.us/page.dna?numero=3D55 Bug Reporting: = support@webdna.us --Apple-Mail=_D4F8330C-C544-4260-8B71-B4FD153AFAC9 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 Thanks Chris,

Nice bit of work/idea.  It=E2=80=99s important that we = are able to sort the database in the same order that the data is listed = in an array.  Looks like your solution would make that possible. =  However, I am in agreement with Tom that if we can get as close as = possible to dot notation or at least mimic the levels or named = parameters of the XMLParse context, that would be optimal. =  

While = working around the JSONStore shortcomings, I ran into multiple = stoppers/bugs that I=E2=80=99ve added to a test suite page = here:


Mike= Davis

On May 6, 2020, at 6:30 AM, talk@webdna.us = wrote:

Chris,

Hi - this would be great.  Just two things to = note:

  • Will the code work for nested arrays?
  • Will it allow for JSON that has colons - = or any character - in the node names?

My view would be that = the closer the WebDNA behaviour matches the behaviour of Javscript the = better.

So = looking at this:

For the following = JSON;

var mydata =3D =   
{"list": =  
  [ =  
    = {"points.bean.pointsBase": =  
    =   [  
    =     {"time": 2000, "caption":"caption text", duration: 5000}, =  
    =     {"time": 6000, "caption":"caption text", duration: 3000} =  
    =   ]  
    = }  
  ] =  
}

The time value in = the first item of the array is extracted using:

var smth =3D = mydata.list[0]["points.bean.pointsBase"][0].time;
I realise square brackets = have special significance in WebDNA, but you get = the idea.

- = Tom



On Wed, 6 May 2020 at 08:24, <talk@webdna.us> = wrote:
Hello everyone!


With Josh (who is behind all the C++ code these last years), we spent = some time thinking about this. He made a proof of concept C++ app that = gives the below output when we feed it the JSON from Mike's post to the = mailing list. Is this useful? If this is acceptable, we can adapt the = code into the WebDNA source tree and have it store in the DB/table in = that format.

page=3D1
total_results=3D21
total_pages=3D1
results:1:popularity=3D1.936
results:1:vote_count=3D7
results:2:popularity=3D2.732
results:2:vote_count=3D23
results:3:popularity=3D12.088
results:3:vote_count=3D75
results:4:popularity=3D53.221
results:4:vote_count=3D5
results:5:popularity=3D7.001
results:5:vote_count=3D31
results:6:popularity=3D22.223
results:6:vote_count=3D88

Next version would have this fix built-in.

- chris


> On May 1, 2020, at 06:03, talk@webdna.us wrote:
>
> Hi Mike.
>
> Ah yes, I can see why you need to do it natively.
>
> Sorry, I am out of silver bullets now :(
>
>
> Kind regards
>
> Stuart Tremain
> Pharoah Lane Software
> AUSTRALIA
> webdna@plsoftware.com.au
>
>
>
>
>
>
>
>> On 1 May 2020, at 12:52, talk@webdna.us wrote:
>>
>> Stuart,
>>
>> I actually use this (Tom=E2=80=99s routine) as the basis of = what I=E2=80=99m doing now.  The challenge I=E2=80=99m facing in my = current project is that the source JSON is quite large, and the specific = data I need is near the end of the data, nested in several layers of = arrays.  The parsing time is around 90 seconds.  I need to = speed that up.
>>
>>
>> Mike Davis
>>
>>> On Apr 30, 2020, at 5:04 PM, talk@webdna.us wrote:
>>>
>>> I am not sure if this is exactly what Tom wrote, but it is = what I am using.
>>>
>>>
>>> [!]------------------- Pass json as JSONRESULT = -----------------
>>> ------------------- Conversion table to strip non-breaking = spaces -----------------
>>> [/!][TABLE name=3DjsonClean&fields=3Dfrom,to]
>>> %C2
>>> %A0
>>> [/TABLE][!]
>>>
>>> ------------------- Conversion table to facilitate spliting = into key:value pairs -----------------
>>> [/!][TABLE name=3DjsonSplitConversions&fields=3Dfrom,to]<= br class=3D""> >>> |   ~~~~
>>> \"  ^^^^
>>> [/TABLE][!]
>>>
>>> ------------------- Convert back after spliting into = key:value pairs -----------------
>>> [/!][TABLE = name=3DjsonSplitConversionsBack&fields=3Dfrom,to]
>>> "   
>>> ~~~~        |
>>> ^^^^        "
>>> [/TABLE][!]
>>>
>>> ------------------- pass one - run the conversions = -----------------
>>> [/!][text]JSONRESULT=3D[CONVERTWORDS = table=3DjsonSplitConversions][convertchars = table=3DjsonClean][JSONRESULT][/convertchars][/CONVERTWORDS][/TEXT][!]
>>>
>>> ------------------- pass two - add bar to just before each = key:value pair -----------------
>>> [/!][text]JSONRESULT=3D[GREP = search=3D("[^"]*"):&replace=3D|\1=3D][JSONRESULT][/GREP][/TEXT][!]
>>>
>>> ------------------- pass three - list out the key:value = pairs and assign them to text variables -----------------
>>> [/!][LISTWORDS = words=3D[url][JSONRESULT][/url]&delimiters=3D|{}][!]
>>>     [/!][text]THISVAL=3D[GREP = search=3D(,$)&replace=3D][GETCHARS = start=3D1&trim=3Dboth][CONVERTWORDS = table=3DjsonSplitConversionsBack][word][/CONVERTWORDS][/GETCHARS][/GREP][/= TEXT][!]
>>>     [/!][HIDEIF [url][THISVAL][/url]=3D][!] >>>            =  [/!][text]JSON-[THISVAL][/TEXT][!]
>>>     [/!][/HIDEIF][!]
>>> [/!][/LISTWORDS]
>>>
>>>
>>>
>>>
>>>
>>> Kind regards
>>>
>>> Stuart Tremain
>>> Pharoah Lane Software
>>> AUSTRALIA
>>> webdna@plsoftware.com.au
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>> On 1 May 2020, at 08:10, talk@webdna.us wrote:
>>>>
>>>> Hi Stuart,
>>>>
>>>> I appreciate your answer and have a similar kludge = (creative solution) for my application.  I was actually hoping to = hear from Chris on this, in hopes that the underlying JSON parser he is = using can be passed dot notation in a similar way that Javascript uses = to parse JSON objects.
>>>>
>>>> Chris, are there any parameters we can send that are = not in the documentation?
>>>>
>>>>
>>>>
>>>> Thanks,
>>>> Mike Davis
>>>>
>>>>> On Apr 22, 2020, at 5:05 PM, talk@webdna.us wrote:
>>>>>
>>>>> Hi MD
>>>>>
>>>>> As we don=E2=80=99t know the email address of the = sender anymore it would be nice for us to know who we are addressing.
>>>>>
>>>>> The JSONStore tag is a little confusing and what is = also not well documented is that you can store the data in a table = eg:
>>>>>
>>>>>
>>>>> [JSONstore = table=3DTRANSACTION&fields=3Derror:type,error:message]
>>>>> [STRIPERESPONSE]
>>>>> [/JSONstore]
>>>>>
>>>>> Then search the table:
>>>>>
>>>>> [SEARCH = table=3DTRANSACTION&neERROR:TYPEdatarq=3D[BLANK]][!]
>>>>>   [/!][founditems][!]
>>>>>          =  [/!][text]ERROR-TYPE=3D[ERROR:TYPE][/TEXT][!]
>>>>>          =  [/!][text]ERROR-MESSAGE=3D[ERROR:MESSAGE][/TEXT][!]
>>>>>   [/!][/FOUNDITEMS][!]
>>>>> [/!][/SEARCH]
>>>>>
>>>>>
>>>>> What I found to be a useful exercise was to write = to my specified db and then open it and read the data to see what is = being done with it. JSONsStore will write the headers in a db
>>>>>
>>>>> [JSONstore db=3Dlogs/stripelog.db]
>>>>> [STRIPERESPONSE]
>>>>> [/JSONstore]
>>>>>
>>>>> As the data is often stored in an array you will = have to do a bit of manipulation on the found items.
>>>>>
>>>>> Here is a JSON function that may be useful to = you.
>>>>>
>>>>>
>>>>> = [!]----------------------------------------------------------------------<= br class=3D""> >>>>> FUNCTION Name: WC-JSONvalue
>>>>>   + Description: Pull out a value from a = JSONobject
>>>>>   + Input:
>>>>>         JSONobject =3D = (the json to be parsed) - required
>>>>>         JSONnode =3D (the = node that we want the value of) - required
>>>>>   + usage: [WC-JSONvalue = JSONobject=3D[url]<the-json-object>[/url]&JSONnode=3D<the-jso= n-node>]
>>>>>   +Note: This function MUST receive valid = JSONobject, make sure that there are no line breaks before beginning of = JSON, test your JSON validity here: https://jsonlint.com
>>>>> = ----------------------------------------------------------------------
>>>>> [/!][function name=3DWC-JSONvalue][!]
>>>>>   [/!][text]rRETURN=3D[/text][!]
>>>>>   [/!][text]rJSONobject=3D[/text][!]
>>>>>   [/!][text]rJSONnode=3Dnull[/text][!]
>>>>>   [/!][showif = [url][params_string][/url]^JSONobject][text]rJSONobject=3D[JSONobject][/te= xt][/showif][!]
>>>>>   [/!][showif = [url][params_string][/url]^JSONnode][text]rJSONnode=3D[JSONnode][/text][/s= howif][!]
>>>>>   --------------------  Store the = JSONobject in a table  --------------------
>>>>>   [/!][JSONstore = table=3DJSONdata][rJSONobject][/jsonstore][!]
>>>>>   --------------------  Search the = table  --------------------
>>>>>   [/!][SEARCH = table=3DJSONdata&ne[rJSONnode]data=3Dfind_all][!]
>>>>>          =  [/!][founditems][!]
>>>>>              =     =  [/!][text]rRETURN=3D[interpret][[rJSONnode]][/interpret][/text][!] >>>>>          =  [/!][/founditems][!]
>>>>>   [/!][/SEARCH][!]
>>>>>   --------------------  Return the = value  --------------------
>>>>>   [/!][return][rRETURN][/return][!]
>>>>> [/!][/function]
>>>>>
>>>>> You man need to play around with the json object to = ensure that it is valid json, I found that PayPal json did not = validate.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> Kind regards
>>>>>
>>>>> Stuart Tremain
>>>>> Pharoah Lane Software
>>>>> AUSTRALIA
>>>>> webdna@plsoftware.com.au
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>> On 23 Apr 2020, at 06:45, talk@webdna.us wrote:
>>>>>>
>>>>>> Hi all,
>>>>>>
>>>>>> I=E2=80=99m looking at the docs for the = JSONStore context.  It seems that either the context is lacking = functionality or the documentation is.  I do not see a way to = access nested levels in the JSON, like can be done with XML using = path=3D0:1:2 for example.  Seems like there should be a way to use = dot notation to get at nested data without storing each array in a temp = db, then reparsing each level with JSONStore into another temp db, = etc.
>>>>>>
>>>>>> For example:  I want to iterate the data = sets in the =E2=80=9Cresults=E2=80=9D array into a database.  I can = use JSONStore to populate a table with the fields: page, total_results, = total_pages and results.   Then I can search that table and = run JSONStore on the results field using another database, but this gets = a bit complicated when working with some other data, in which I need to = access data that is 3 or 4 arrays deep.
>>>>>>
>>>>>> Anyone solved this puzzle in a more efficient = way yet?
>>>>>>
>>>>>> {
>>>>>>    "page":1,
>>>>>>    "total_results":21,
>>>>>>    "total_pages":1,
>>>>>>    "results=E2=80=9D:[
>>>>>>        {
>>>>>>            = "popularity":1.936,"vote_count=E2=80=9D:7
>>>>>>        },
>>>>>>        {
>>>>>>            = "popularity=E2=80=9D:2.732,"vote_count=E2=80=9D:23
>>>>>>        },
>>>>>>        {
>>>>>>            = "popularity=E2=80=9D:12.088,"vote_count=E2=80=9D:75
>>>>>>        },
>>>>>>        {
>>>>>>            = "popularity=E2=80=9D:53.221,"vote_count=E2=80=9D:5
>>>>>>        },
>>>>>>        {
>>>>>>            = "popularity=E2=80=9D:7.001,"vote_count=E2=80=9D:31
>>>>>>        },
>>>>>>        {
>>>>>>            = "popularity=E2=80=9D:22.223,"vote_count=E2=80=9D:88
>>>>>>        }
>>>>>>    ]
>>>>>> }
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> = MD---------------------------------------------------------
= >>>>>> This message is sent to you because you are = subscribed to
>>>>>> the mailing list talk@webdna.us
>>>>>> To unsubscribe, E-mail to: talk-leave@webdna.us
>>>>>> archives: http://www.webdna.us/page.dna?numero=3D55
>>>>>> Bug Reporting: support@webdna.us
>>>>>
>>>>> = --------------------------------------------------------- This message = is sent to you because you are subscribed to the mailing list talk@webdna.us To unsubscribe, E-mail to: talk-leave@webdna.us archives: http://www.webdna.us/page.dna?numero=3D55= Bug Reporting: support@webdna.us
>>>>
>>>> = --------------------------------------------------------- This message = is sent to you because you are subscribed to the mailing list talk@webdna.us To unsubscribe, E-mail to: talk-leave@webdna.us archives: http://www.webdna.us/page.dna?numero=3D55= Bug Reporting: support@webdna.us
>>>
>>> --------------------------------------------------------- = This message is sent to you because you are subscribed to the mailing = list talk@webdna.us To unsubscribe, E-mail to: talk-leave@webdna.us archives: http://www.webdna.us/page.dna?numero=3D55= Bug Reporting: support@webdna.us
>>
>> --------------------------------------------------------- This = message is sent to you because you are subscribed to the mailing list talk@webdna.us To unsubscribe, E-mail to: talk-leave@webdna.us archives: http://www.webdna.us/page.dna?numero=3D55= Bug Reporting: support@webdna.us
>
> --------------------------------------------------------- This = message is sent to you because you are subscribed to the mailing list talk@webdna.us To unsubscribe, E-mail to: talk-leave@webdna.us archives: http://www.webdna.us/page.dna?numero=3D55= Bug Reporting: support@webdna.us

---------------------------------------------------------
This message is sent to you because you are subscribed to
the mailing list talk@webdna.us
To unsubscribe, E-mail to: talk-leave@webdna.us
archives: http://www.webdna.us/page.dna?numero=3D55
Bug Reporting: support@webdna.us
--------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list talk@webdna.us To unsubscribe, E-mail to: talk-leave@webdna.us archives: http://www.webdna.us/page.dna?numero=3D55 Bug Reporting: support@webdna.us

= --------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list talk@webdna.us To unsubscribe, E-mail to: talk-leave@webdna.us archives: http://www.webdna.us/page.dna?numero=3D55 Bug Reporting: support@webdna.us --Apple-Mail=_D4F8330C-C544-4260-8B71-B4FD153AFAC9-- . Michael Davis

DOWNLOAD WEBDNA NOW!

Top Articles:

Talk List

The WebDNA community talk-list is the best place to get some help: several hundred extremely proficient programmers with an excellent knowledge of WebDNA and an excellent spirit will deliver all the tips and tricks you can imagine...

Related Readings:

WebCat2 beta 11 - new prefs ... (1997) Math (1997) Sorting problem (2002) security problem (1997) Browser Reloads and AddlineItem (1997) Re:Merging databases (1997) [WebDNA] preventing hackers from posting their own (altered) (2009) Search/sort in URL Was: GuestBook example (1997) WebCat2 - storing unformatted date data? (1997) Robust WebDNA Job Manager / Accountant (2006) Verifying both name and password (was: New Problem) (1997) Date Range Sorting (1997) WebDNA 6 (2004) Sort Order on a page search (1997) Hiding usernames and passwords in URL (1998) Ports? (2002) Problems with [Applescript] (1997) Webcatalog and IIS4b2 (1997) [OT] Happy Turkey Day! (2003) Yet another db manager (2004)