Re: [WebDNA] TCPconnect and Bitcoin rate

This WebDNA talk-list message is from

2017


It keeps the original formatting.
numero = 113893
interpreted = N
texte = 1493 --089e08250780897eb60560bc9b82 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I put that code on a page... was missing a showif... fixed that. You have an example of a paste...? On Tue, Dec 19, 2017 at 4:48 PM, Stuart Tremain wrote: > Hey Tom > > Nice function :) > > > Kind regards > > Stuart Tremain > Pharoah Lane Software > AUSTRALIA > webdna@idfk.com.au > > > > > > > On 19 Dec 2017, at 20:23, Tom Duke wrote: > > Hi all, > > Here is the code I use to deal with JSON. > > - Tom > > > > *First a function to pull a value when you know what JSON node you want:* > > [!] > > > +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > FUNCTION Name: smGetJsonValue > ** Description: Pull out a value from a JSONobject > ** Input: > jsonObject =3D (the json to be parsed) - required > jsonNode =3D (the node that we the value of) - required > ** usage: > [smGetJsonValue jsonObject=3D[url] object>[/url]&jsonNode=3D] > > [/!][function name=3DsmGetJsonValue][!] > [/!][text]tReturn=3D[/text][!] > > [/!][text]tJsonObject=3D[/text][!] > [/!][text]tJsonNode=3Dnull[/text][!] > > [/!][showif [url][params_string][/url]^jsonObject][text]tJsonObject=3D[ > jsonObject][/text][/showif][!] > [/!][showif [url][params_string][/url]^jsonNode][text]tJsonNode=3D[ > jsonNode][/text][/showif][!] > > ### Store the jsonObject in a table ### > > [/!][jsonstore table=3DjsonOject][tJsonObject][/jsonstore][!] > > ### Search the table ### > > [/!][search table=3DjsonOject&ne[tJsonNode]data=3Dfind_all][founditems][!= ] > > [/!][text]tReturn=3D[interpret][[tJsonNode]][/interpret][/text][!] > > [/!][/founditems][/search][!] > > ### Return the value ### > > [/!][return][tReturn][/return][!] > [/!][/function] > > > > > *Second a Json parser, that's a bit of a hack:* > > [text]debug=3DF[/text] > >

Paste some JSON

>

(some samples here json/10-example-json-files/">http://www.jquery4u.com/json/ > 10-example-json-files/)

>
> >
> >
> > > [showif [action]=3Dparse-json] > >

Sample JSON

>
[text show=3DT]theJson=3D[sample-json][/text]


> > > [!] > > > ------------------------------------ > ### 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] > | ~~~~ > \" ^^^^ > [/table][!] > > > ------------------------------------ > ### Convert back after spliting into key:value pairs ### > > [/!][table name=3DjsonSplitConversionsBack&fields=3Dfrom,to] > " > ~~~~ | > ^^^^ " > [/table][!] > > > ------------------------------------ > ### pass one - run the conversions ### > > [/!][text]theJson=3D[convertwords table=3DjsonSplitConversions][convertch= ars > table=3DjsonClean][theJson][/convertchars][/convertwords][/text][!] > > > ------------------------------------ > ### pass two - add bar to just before each key:value pair ### > > [/!][text]theJson=3D[grep search=3D("[^"]*"):&replace=3D|\1=3D > ][theJson][/grep][/text][!] > > > ------------------------------------ > ### pass three - list out the key:value pairs and assign them to text > variables ### > > [/!][text]count=3D0[/text][listwords words=3D[url][theJson][/url]& > delimiters=3D|{}][!] > > [/!][text]thisVal=3D[grep search=3D(,$)&replace=3D][getchars start=3D1&tr= im=3Dboth][convertwords > table=3DjsonSplitConversionsBack][word][/convertwords][/ > getchars][/grep][/text][!] > [/!][showif [debug]=3DT][index]. [url][thisVal][/url]
[/showif][!] > [/!][hideif [url][thisVal][/url]=3D][!] > [/!][text]json-[format .2d][text show=3DT]count=3D[math][count]+1[/ > math][/text][/format]-[thisVal][/text][!] > [/!][/hideif][!] > > [/!][/listwords][!] > > > ------------------------------------ > ### Let's have a look at the variables ### > > [/!]

JSON Assigned to Text Variables

> [listvariables name=3Djson-&exact=3DF][name] =3D [value]
> [/listvariables] > > [/showif] > > > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > Digital Revolutionaries > 1st Floor, Castleriver House > 14-15 Parliament Street > > Temple Bar,Dublin > > 2 > Ireland > ---------------------------------------------- > [t]: + 353 1 4403907 <+353%201%20440%203907> > [e]: > [w]: > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > On 19 December 2017 at 08:01, Terry Nair wrote: > >> Kindly point out the link where I can find that JSON wonder =E2=80=A6nee= d it for >> a project. Cannot seem to trace it =E2=80=A6my poor old eyes are not as = good as >> they used to be =E2=80=A6=F0=9F=98=89 >> >> >> >> Cheers TDn >> >> >> >> *From:* Stuart Tremain [mailto:webdna@idfk.com.au] >> *Sent:* Tuesday, December 19, 2017 08:19 AM >> *To:* WebDNA Talk List >> *Subject:* Re: [WebDNA] TCPconnect and Bitcoin rate >> >> >> >> OK, thanks. >> >> >> >> Tom if that was you - nice job, have been using it for a few years now := ) >> >> >> >> >> >> Kind regards >> >> >> >> Stuart Tremain >> >> Pharoah Lane Software >> >> AUSTRALIA >> >> webdna@idfk.com.au >> >> >> >> >> >> >> >> >> >> >> >> On 19 Dec 2017, at 11:15, Michael Davis wrote: >> >> >> >> Stuart, >> >> >> >> I think that was Tom. He had worked one up prior to JSONStore. >> >> >> >> Mike >> >> >> >> On Dec 18, 2017, at 3:32 PM, Stuart Tremain wrote: >> >> >> >> Michael >> >> >> >> Were you the person that did the JSON parser some time ago ? >> >> >> >> >> >> Kind regards >> >> >> >> Stuart Tremain >> >> Pharoah Lane Software >> >> AUSTRALIA >> >> webdna@idfk.com.au >> >> >> >> >> >> >> >> >> >> >> >> On 19 Dec 2017, at 10:22, Michael Davis wrote: >> >> >> >> Yariv, >> >> >> >> Here's a starting point for you... >> >> >> >> Had to use [middle] to get rid of some garbage, which was strange. Othe= r >> than that, it should be pretty straight forward. >> >> >> >> >> >> --------------------------------------------------------- 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 >> >> >> >> >> >> >> On Dec 17, 2017, at 3:54 AM, Office wrote: >> >> >> >> For the last 20 years i never had to receive data from elsewhere till >> today. >> >> I need to ask an API for the bitcoin rate >> >> i wanted to use the TCPconnect for this but the sample is dead ? : >> >> >> >> http://www.webdna.us/page.dna?numero=3D264 >> >> >> >> What i need is a piece of code to get the USD =E2=80=9Crate" out of this= thing >> (this number: 19,681.9725) so i can calculate the price of the product t= o >> be divided to this to be able to show the current price in Bitcoin at my >> store >> >> {"USD":{"code":"USD","symbol":"$","rate":"19,681.9725","description"= :"United States Dollar","rate_float":19681.9725} >> >> This is where it update every second (or less) >> >> https://api.coindesk.com/v1/bpi/currentprice.json >> >> >> >> Or any other way to get a rate into my page :-) >> >> >> >> Yours, >> >> >> >> Yariv Nachshon >> >> http://www.plonter.co.il >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> --------------------------------------------------------- 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.u= s > > > --------------------------------------------------------- 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.u= s > --089e08250780897eb60560bc9b82 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I put that code on a page... was missing a showif... fixed= that. You have an example of a paste...?
<= br>
On Tue, Dec 19, 2017 at 4:48 PM, Stuart Trema= in <webdna@idfk.com.au> wrote:
Hey = Tom

Nice function :)


Kind r= egards

Stuart Tremain
Pharoah Lane Softw= are
AUSTRALIA


<= /span>
<= br class=3D"m_-2021121088248998294Apple-interchange-newline">

On 19= Dec 2017, at 20:23, Tom Duke <tom@revolutionaries.ie> wrote:

Hi a= ll,

Here is the code I use to deal with JSON.
=
- Tom



First a function to pull a value when you know what JSON node you want:=

[!]<= /font>

=
+++++++++++++++++++++++++++++++++++++++++++++++++++= ++++++++
FUNCTION Name= : smGetJsonValue
=C2= =A0 ** Description: Pull out a value from a JSONobject
=C2=A0 ** Input:=C2=A0
=C2=A0 =C2=A0 =C2=A0 =C2=A0 jsonObject = =3D (the json to be parsed) - required
=C2=A0 =C2=A0 =C2=A0 =C2=A0 jsonNode =3D (the node that we= the value of) - required
=C2=A0 ** usage:=C2=A0
=C2=A0 =C2=A0 =C2=A0 =C2=A0 [smGetJsonValue jsonObject=3D[url]<the-= json-object>[/url]&jsonNode=3D<the-json-node>]

[/!][function name=3DsmGetJsonValue][!]
[/!][text]tReturn=3D[/text= ][!]

=
[/!][text]t= JsonObject=3D[/text][!]
[/!][text]tJsonNode=3Dnull[/text][!]

[/!][showif [url][p= arams_string][/url]^jsonObject][text]tJsonObject=3D[jsonObject][/= text][/showif][!]
[/!][showif [url][params_string][/url]^jsonNode][te= xt]tJsonNode=3D[jsonNode][/text][/showif][!]

### =C2=A0Store the jsonObject in a table= =C2=A0###

=
[/!][jsonstore table=3DjsonO= ject][tJsonObject][/jsonstore][!]

= ### =C2=A0Search the table =C2=A0###

[/!][search table=3DjsonOject&ne[tJsonNode]da= ta=3Dfind_all][founditems][!]

[/!][text]tReturn=3D[interpret][[tJsonNode]][/interpret]= [/text][!]

[/!][/founditems][/sear= ch][!]

### =C2= =A0Return the value =C2=A0###

[/!][retu= rn][tReturn][/return][!]
[/!][/function]




Second a Json parser, that's a bit o= f a hack:

[text]debug=3DF[/text]

<h3>P= aste some JSON</h3>
<form action=3D&q= uot;[thisurl]" method=3D"post">
<input type=3D"hidden" name=3D&quo= t;action" value=3D"parse-json" />
<textarea name=3D"sample-json" s= tyle=3D"width: 50%; height: 200px;" placeholder=3D"paste som= e json"></textarea><br />
<button>Parse me</button>
</form>


= [showif [action]=3Dparse-json]

<h3&g= t;Sample JSON</h3>
<pre>[text show=3DT]theJson=3D[sample-json][/text]</pre>= ;<br /><br />


[!]


------------------------------------
= ### =C2=A0Conver= sion table to strip non-breaking spaces ###

[/!][table name=3DjsonClean&fields=3Dfrom,to]
%C2
%A0
[/table][!]


<= span class=3D"m_-2021121088248998294gmail-Apple-tab-span" style=3D"white-sp= ace:pre-wrap">------------------------------------
### =C2=A0= Conversion table to facilitate spliting into key:value pairs =C2=A0###

[/!][table name=3DjsonSplitConversions&= fields=3Dfrom,to]
|~~~~
\"^^^^
[/table][!]


= ------------------------------------
### =C2=A0Convert back after spl= iting into key:value pairs =C2=A0###

[/= !][table name=3DjsonSplitConversionsBack&fields=3Dfrom,to]<= /div>
"=
~~~~<= /span>|
^^^^"
[/= table][!]

<= /div>

-----------------------= -------------
### =C2=A0pass one - run the conversions =C2=A0###

[/!][text]theJson=3D[convertwords tabl= e=3DjsonSplitConversions][convertchars table=3DjsonClean][theJson][/convertchars][/convertwords][/text][!]


------------------------------------
<= font face=3D"monospace, monospace">### =C2=A0pass tw= o - add bar to just before each key:value pair ###

[/!][text]theJson=3D[grep search=3D("[^"]*"):&am= p;replace=3D|\1=3D][theJson][/grep][/text][!]


------------------------------------
### =C2=A0pass= three - list out the key:value pairs and assign them to text variables =C2= =A0###

[/!][text]count=3D0[/text][= listwords words=3D[url][theJson][/url]&delimiters=3D|{}][!]=

[/!][text]thisVal=3D[g= rep search=3D(,$)&replace=3D][getchars start=3D1&trim=3Dboth][= convertwords table=3DjsonSplitConversionsBack][word][/convertword= s][/getchars][/grep][/text][!]

[/!][showif [debug]=3DT][index]. [ur= l][thisVal][/url]<br />[/showif][!]
<= font face=3D"monospace, monospace">
[/!][hideif [url][thisVal][/ur= l]=3D][!]
[/!][text]json-[format .2d][text show=3DT]count=3D[math][count= ]+1[/math][/text][/format]-[thisVal][/text][!]
<= font face=3D"monospace, monospace">[/!][/hideif][!]<= /font>

= [/!][/listwords][!]


= ------------------------------------
### =C2= =A0Let's have a look at the variables =C2=A0###

[/!]<h3>JSON Assigned to Text Variables</h3>
[listvariables name=3Djson-= &exact=3DF][name] =3D [value]<br />
[/listvariables]

[/showif]



= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Dig= ital Revolutionaries
1st Floor, Castleriver House
14-15 Parliament Street
Temple Bar,Dublin 2
Ireland
------------------------= ----------------------
[t]: + 353 1 4403907
[e]: <mai= lto:tom@revolut= ionaries.ie>
[w]: <http://www.revolutionaries.ie/>
=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

On 19 December 2017 at 08:01, Terry Nair <terrynair@prism4u.com> wrote:

Kindly point out the link where I can find that JSON wonde= r =E2=80=A6need it for a project. Cannot seem to trace it =E2=80=A6my poor = old eyes are not as good as they used to be =E2=80=A6=F0=9F=98=89

=C2=A0

Cheers TDn

=C2=A0

From: Stuart Tremain [mai= lto:webdna@idfk.com= ..au]
Sent: Tuesday, December 19, 2017 08:19 AM
To:= WebDNA Talk List <t= alk@webdna.us>
Subject: Re: [WebDNA] TCPconnect and Bitcoi= n rate

=C2=A0

OK, thanks.

=C2= =A0

Tom if that was you - nice = job, have been using it for a few years now :)

=

=C2=A0

=C2=A0

Kind rega= rds

=C2=A0

Stuart Tremain

=

Pharoah Lane Software

AUSTRALIA

=C2=A0

=C2=A0

=C2=A0

=C2=A0



On 19 Dec 2017, at 11:15, Mi= chael Davis <ad= min@network13.net> wrote:

=C2=A0

Stuart,=

=C2=A0

<= p class=3D"MsoNormal">I think that was Tom.=C2=A0 He had worked one up prio= r to JSONStore.

= =C2=A0

Mike



= On Dec 18, 2017, at 3:32 PM, Stuart Tremain <webdna@idfk.com.au> wrote:

=C2=A0

Michael

=C2=A0

Were you the person tha= t did the JSON parser some time ago ?

=C2=A0

=C2=A0

Kin= d regards

=C2=A0

Stuart Tremai= n

Pharoah Lane = Software

AUSTRA= LIA

=C2=A0

=C2=A0

=C2=A0

=C2=A0



On 19 De= c 2017, at 10:22, Michael Davis <admin@network13.net> wrote:

=C2=A0

Yariv,

=C2=A0<= /u>

Here's a starting point for yo= u...

=C2=A0

Had to use [middle] to get rid of so= me garbage, which was strange.=C2=A0 Other than that, it should be pretty s= traight forward.

= =C2=A0

=C2=A0

=

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

=C2=A0=



O= n Dec 17, 2017, at 3:54 AM, Office <yariv.n@gmail.com> wrote:

=

=C2=A0

For the last 20 years i never had to receive data from elsewhere till = today.

I need to ask an API fo= r the bitcoin rate

i wan= ted to use the TCPconnect for this but the sample is dead ? :=

=C2=A0

=C2=A0

What i need is a piece of code to get the USD= =E2=80=9Crate" out of this thing (this number: 19,681.9725) so i can = calculate the price of the product to be divided to this to be able to show= the current price in Bitcoin at my store

={"USD":{"code":"USD","symbol":="&#36;","rate":"19,681.9725","d=escription":"United States Dollar","rate_float":19=681.9725}

This is where= it update every second (or less)

=C2=A0

Or any other way to get a rate into = my page :-)

=C2= =A0

Yours,

=C2=A0

Yariv Nachshon

= =C2=A0

=C2=A0

=

=C2=A0



=C2=A0

= =C2=A0


=

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

=C2=A0

=C2=A0

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

=C2=A0

=

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

=C2=A0

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

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

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

--------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list talk@w= ebdna.us To unsubscribe, E-mail to: talk-leave@webdna.us archives: http://www.webdna.us/page.dna?numero=3D55 Bug Reporting: suppo= rt@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 --089e08250780897eb60560bc9b82-- . Associated Messages, from the most recent to the oldest:

    
  1. Re: [WebDNA] TCPconnect and Bitcoin rate (Stuart Tremain 2019)
  2. Re: [WebDNA] TCPconnect and Bitcoin rate (Michael Davis 2019)
  3. Re: [WebDNA] TCPconnect and Bitcoin rate (Stuart Tremain 2017)
  4. Re: [WebDNA] TCPconnect and Bitcoin rate (Brian Harrington 2017)
  5. Re: [WebDNA] TCPconnect and Bitcoin rate (Stuart Tremain 2017)
  6. Re: [WebDNA] TCPconnect and Bitcoin rate (Stuart Tremain 2017)
  7. Re: [WebDNA] TCPconnect and Bitcoin rate (Tom Duke 2017)
  8. RE: [WebDNA] TCPconnect and Bitcoin rate ("Terry Nair" 2017)
  9. Re: [WebDNA] TCPconnect and Bitcoin rate (Stuart Tremain 2017)
  10. Re: [WebDNA] TCPconnect and Bitcoin rate (Michael Davis 2017)
  11. Re: [WebDNA] TCPconnect and Bitcoin rate (Stuart Tremain 2017)
  12. Re: [WebDNA] TCPconnect and Bitcoin rate (Michael Davis 2017)
  13. Re: [WebDNA] TCPconnect and Bitcoin rate (Office 2017)
  14. Re: [WebDNA] TCPconnect and Bitcoin rate (Stuart Tremain 2017)
  15. [WebDNA] TCPconnect and Bitcoin rate (Yariv Nachshon 2017)
  16. Re: [WebDNA] TCPconnect and Bitcoin rate (Lawrence Banahan 2017)
  17. [WebDNA] TCPconnect and Bitcoin rate (Office 2017)
1493 --089e08250780897eb60560bc9b82 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I put that code on a page... was missing a showif... fixed that. You have an example of a paste...? On Tue, Dec 19, 2017 at 4:48 PM, Stuart Tremain wrote: > Hey Tom > > Nice function :) > > > Kind regards > > Stuart Tremain > Pharoah Lane Software > AUSTRALIA > webdna@idfk.com.au > > > > > > > On 19 Dec 2017, at 20:23, Tom Duke wrote: > > Hi all, > > Here is the code I use to deal with JSON. > > - Tom > > > > *First a function to pull a value when you know what JSON node you want:* > > [!] > > > +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > FUNCTION Name: smGetJsonValue > ** Description: Pull out a value from a JSONobject > ** Input: > jsonObject =3D (the json to be parsed) - required > jsonNode =3D (the node that we the value of) - required > ** usage: > [smGetJsonValue jsonObject=3D[url] object>[/url]&jsonNode=3D] > > [/!][function name=3DsmGetJsonValue][!] > [/!][text]tReturn=3D[/text][!] > > [/!][text]tJsonObject=3D[/text][!] > [/!][text]tJsonNode=3Dnull[/text][!] > > [/!][showif [url][params_string][/url]^jsonObject][text]tJsonObject=3D[ > jsonObject][/text][/showif][!] > [/!][showif [url][params_string][/url]^jsonNode][text]tJsonNode=3D[ > jsonNode][/text][/showif][!] > > ### Store the jsonObject in a table ### > > [/!][jsonstore table=3DjsonOject][tJsonObject][/jsonstore][!] > > ### Search the table ### > > [/!][search table=3DjsonOject&ne[tJsonNode]data=3Dfind_all][founditems][!= ] > > [/!][text]tReturn=3D[interpret][[tJsonNode]][/interpret][/text][!] > > [/!][/founditems][/search][!] > > ### Return the value ### > > [/!][return][tReturn][/return][!] > [/!][/function] > > > > > *Second a Json parser, that's a bit of a hack:* > > [text]debug=3DF[/text] > >

Paste some JSON

>

(some samples here json/10-example-json-files/">http://www.jquery4u.com/json/ > 10-example-json-files/)

>
[thisurl]" method=3D"post"> > >
> >
> > > [showif [action]=3Dparse-json] > >

Sample JSON

>
[text show=3DT]theJson=3D[sample-json][/text]


> > > [!] > > > ------------------------------------ > ### 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] > | ~~~~ > \" ^^^^ > [/table][!] > > > ------------------------------------ > ### Convert back after spliting into key:value pairs ### > > [/!][table name=3DjsonSplitConversionsBack&fields=3Dfrom,to] > " > ~~~~ | > ^^^^ " > [/table][!] > > > ------------------------------------ > ### pass one - run the conversions ### > > [/!][text]theJson=3D[convertwords table=3DjsonSplitConversions][convertch= ars > table=3DjsonClean][theJson][/convertchars][/convertwords][/text][!] > > > ------------------------------------ > ### pass two - add bar to just before each key:value pair ### > > [/!][text]theJson=3D[grep search=3D("[^"]*"):&replace=3D|\1=3D > ][theJson][/grep][/text][!] > > > ------------------------------------ > ### pass three - list out the key:value pairs and assign them to text > variables ### > > [/!][text]count=3D0[/text][listwords words=3D[url][theJson][/url]& > delimiters=3D|{}][!] > > [/!][text]thisVal=3D[grep search=3D(,$)&replace=3D][getchars start=3D1&tr= im=3Dboth][convertwords > table=3DjsonSplitConversionsBack][word][/convertwords][/ > getchars][/grep][/text][!] > [/!][showif [debug]=3DT][index]. [url][thisVal][/url]
[/showif][!] > [/!][hideif [url][thisVal][/url]=3D][!] > [/!][text]json-[format .2d][text show=3DT]count=3D[math][count]+1[/ > math][/text][/format]-[thisVal][/text][!] > [/!][/hideif][!] > > [/!][/listwords][!] > > > ------------------------------------ > ### Let's have a look at the variables ### > > [/!]

JSON Assigned to Text Variables

> [listvariables name=3Djson-&exact=3DF][name] =3D [value]
> [/listvariables] > > [/showif] > > > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > Digital Revolutionaries > 1st Floor, Castleriver House > 14-15 Parliament Street > > Temple Bar,Dublin > > 2 > Ireland > ---------------------------------------------- > [t]: + 353 1 4403907 <+353%201%20440%203907> > [e]: > [w]: > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > On 19 December 2017 at 08:01, Terry Nair wrote: > >> Kindly point out the link where I can find that JSON wonder =E2=80=A6nee= d it for >> a project. Cannot seem to trace it =E2=80=A6my poor old eyes are not as = good as >> they used to be =E2=80=A6=F0=9F=98=89 >> >> >> >> Cheers TDn >> >> >> >> *From:* Stuart Tremain [mailto:webdna@idfk.com.au] >> *Sent:* Tuesday, December 19, 2017 08:19 AM >> *To:* WebDNA Talk List >> *Subject:* Re: [WebDNA] TCPconnect and Bitcoin rate >> >> >> >> OK, thanks. >> >> >> >> Tom if that was you - nice job, have been using it for a few years now := ) >> >> >> >> >> >> Kind regards >> >> >> >> Stuart Tremain >> >> Pharoah Lane Software >> >> AUSTRALIA >> >> webdna@idfk.com.au >> >> >> >> >> >> >> >> >> >> >> >> On 19 Dec 2017, at 11:15, Michael Davis wrote: >> >> >> >> Stuart, >> >> >> >> I think that was Tom. He had worked one up prior to JSONStore. >> >> >> >> Mike >> >> >> >> On Dec 18, 2017, at 3:32 PM, Stuart Tremain wrote: >> >> >> >> Michael >> >> >> >> Were you the person that did the JSON parser some time ago ? >> >> >> >> >> >> Kind regards >> >> >> >> Stuart Tremain >> >> Pharoah Lane Software >> >> AUSTRALIA >> >> webdna@idfk.com.au >> >> >> >> >> >> >> >> >> >> >> >> On 19 Dec 2017, at 10:22, Michael Davis wrote: >> >> >> >> Yariv, >> >> >> >> Here's a starting point for you... >> >> >> >> Had to use [middle] to get rid of some garbage, which was strange. Othe= r >> than that, it should be pretty straight forward. >> >> >> >> >> >> --------------------------------------------------------- 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 >> >> >> >> >> >> >> On Dec 17, 2017, at 3:54 AM, Office wrote: >> >> >> >> For the last 20 years i never had to receive data from elsewhere till >> today. >> >> I need to ask an API for the bitcoin rate >> >> i wanted to use the TCPconnect for this but the sample is dead ? : >> >> >> >> http://www.webdna.us/page.dna?numero=3D264 >> >> >> >> What i need is a piece of code to get the USD =E2=80=9Crate" out of this= thing >> (this number: 19,681.9725) so i can calculate the price of the product t= o >> be divided to this to be able to show the current price in Bitcoin at my >> store >> >> {"USD":{"code":"USD","symbol":"$","rate":"19,681.9725","description"= :"United States Dollar","rate_float":19681.9725} >> >> This is where it update every second (or less) >> >> https://api.coindesk.com/v1/bpi/currentprice.json >> >> >> >> Or any other way to get a rate into my page :-) >> >> >> >> Yours, >> >> >> >> Yariv Nachshon >> >> http://www.plonter.co.il >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> --------------------------------------------------------- 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.u= s > > > --------------------------------------------------------- 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.u= s > --089e08250780897eb60560bc9b82 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I put that code on a page... was missing a showif... fixed= that. You have an example of a paste...?
--------------------------------------------------------- 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 --089e08250780897eb60560bc9b82-- . Brian Harrington

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:

WebDNA still will not start on restart (2002) Re[2]: 2nd WebCatalog2 Feature Request (1996) writefile and texte (1997) Encrypt and Commit Me (1998) Order not created error (never mind) (1997) [ignore this] Wierd display error.... (2004) err... DEVELOPER (2001) WC1.6 to WC2 date formatting (1997) Clearly.home (1998) [TaxableTotal] - not working with AOL and IE (1997) Multiple prices (1997) Suggestion: appendfounditems (2002) [ShowNext] (1997) WebCatalog 3.0.8 is on FTP... (2000) Ampersand (1997) Re:2nd WebCatalog2 Feature Request (1996) WebCat Code and WebStar Search? (2000) emailer w/F2 (1997) WebCatalog for Postcards ? (1997) [price] via a search (1998)
<= br>
On Tue, Dec 19, 2017 at 4:48 PM, Stuart Trema= in <webdna@idfk.com.au> wrote:
Hey = Tom

Nice function :)


Kind r= egards

Stuart Tremain
Pharoah Lane Softw= are
AUSTRALIA


<= /span>
<= br class=3D"m_-2021121088248998294Apple-interchange-newline">

On 19= Dec 2017, at 20:23, Tom Duke <tom@revolutionaries.ie> wrote:

Hi a= ll,

Here is the code I use to deal with JSON.
=
- Tom



First a function to pull a value when you know what JSON node you want:=

[!]<= /font>

=
+++++++++++++++++++++++++++++++++++++++++++++++++++= ++++++++
FUNCTION Name= : smGetJsonValue
=C2= =A0 ** Description: Pull out a value from a JSONobject
=C2=A0 ** Input:=C2=A0
=C2=A0 =C2=A0 =C2=A0 =C2=A0 jsonObject = =3D (the json to be parsed) - required
=C2=A0 =C2=A0 =C2=A0 =C2=A0 jsonNode =3D (the node that we= the value of) - required
=C2=A0 ** usage:=C2=A0
=C2=A0 =C2=A0 =C2=A0 =C2=A0 [smGetJsonValue jsonObject=3D[url]<the-= json-object>[/url]&jsonNode=3D<the-json-node>]

[/!][function name=3DsmGetJsonValue][!]
[/!][text]tReturn=3D[/text= ][!]

=
[/!][text]t= JsonObject=3D[/text][!]
[/!][text]tJsonNode=3Dnull[/text][!]

[/!][showif [url][p= arams_string][/url]^jsonObject][text]tJsonObject=3D[jsonObject][/= text][/showif][!]
[/!][showif [url][params_string][/url]^jsonNode][te= xt]tJsonNode=3D[jsonNode][/text][/showif][!]

### =C2=A0Store the jsonObject in a table= =C2=A0###

=
[/!][jsonstore table=3DjsonO= ject][tJsonObject][/jsonstore][!]

= ### =C2=A0Search the table =C2=A0###

[/!][search table=3DjsonOject&ne[tJsonNode]da= ta=3Dfind_all][founditems][!]

[/!][text]tReturn=3D[interpret][[tJsonNode]][/interpret]= [/text][!]

[/!][/founditems][/sear= ch][!]

### =C2= =A0Return the value =C2=A0###

[/!][retu= rn][tReturn][/return][!]
[/!][/function]




Second a Json parser, that's a bit o= f a hack:

[text]debug=3DF[/text]

<h3>P= aste some JSON</h3>
<form action=3D&q= uot;[thisurl]" method=3D"post">
<input type=3D"hidden" name=3D&quo= t;action" value=3D"parse-json" />
<textarea name=3D"sample-json" s= tyle=3D"width: 50%; height: 200px;" placeholder=3D"paste som= e json"></textarea><br />
<button>Parse me</button>
</form>


= [showif [action]=3Dparse-json]

<h3&g= t;Sample JSON</h3>
<pre>[text show=3DT]theJson=3D[sample-json][/text]</pre>= ;<br /><br />




------------------------------------
= ### =C2=A0Conver= sion table to strip non-breaking spaces ###

[/!][table name=3DjsonClean&fields=3Dfrom,to]
%C2
%A0
[/table][!]


<= span class=3D"m_-2021121088248998294gmail-Apple-tab-span" style=3D"white-sp= ace:pre-wrap">------------------------------------
### =C2=A0= Conversion table to facilitate spliting into key:value pairs =C2=A0###

[/!][table name=3DjsonSplitConversions&= fields=3Dfrom,to]
|~~~~
\"^^^^
[/table][!]


= ------------------------------------
### =C2=A0Convert back after spl= iting into key:value pairs =C2=A0###

[/= !][table name=3DjsonSplitConversionsBack&fields=3Dfrom,to]<= /div>
"=
~~~~<= /span>|
^^^^"
[/= table][!]

<= /div>

-----------------------= -------------
### =C2=A0pass one - run the conversions =C2=A0###

[/!][text]theJson=3D[convertwords tabl= e=3DjsonSplitConversions][convertchars table=3DjsonClean][theJson][/convertchars][/convertwords][/text][!]


------------------------------------
<= font face=3D"monospace, monospace">### =C2=A0pass tw= o - add bar to just before each key:value pair ###

[/!][text]theJson=3D[grep search=3D("[^"]*"):&am= p;replace=3D|\1=3D][theJson][/grep][/text][!]


------------------------------------
### =C2=A0pass= three - list out the key:value pairs and assign them to text variables =C2= =A0###

[/!][text]count=3D0[/text][= listwords words=3D[url][theJson][/url]&delimiters=3D|{}][!]=

[/!][text]thisVal=3D[g= rep search=3D(,$)&replace=3D][getchars start=3D1&trim=3Dboth][= convertwords table=3DjsonSplitConversionsBack][word][/convertword= s][/getchars][/grep][/text][!]

[/!][showif [debug]=3DT][index]. [ur= l][thisVal][/url]<br />[/showif][!]
<= font face=3D"monospace, monospace">
[/!][hideif [url][thisVal][/ur= l]=3D][!]
[/!][text]json-[format .2d][text show=3DT]count=3D[math][count= ]+1[/math][/text][/format]-[thisVal][/text][!]
<= font face=3D"monospace, monospace">[/!][/hideif][!]<= /font>

= [/!][/listwords][!]


= ------------------------------------
### =C2= =A0Let's have a look at the variables =C2=A0###

[/!]<h3>JSON Assigned to Text Variables</h3>
[listvariables name=3Djson-= &exact=3DF][name] =3D [value]<br />
[/listvariables]

[/showif]



= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Dig= ital Revolutionaries
1st Floor, Castleriver House
14-15 Parliament Street
Temple Bar,Dublin 2
Ireland
------------------------= ----------------------
[t]: + 353 1 4403907
[e]: <mai= lto:tom@revolut= ionaries.ie>
[w]: <http://www.revolutionaries.ie/>
=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

On 19 December 2017 at 08:01, Terry Nair <terrynair@prism4u.com> wrote:

Kindly point out the link where I can find that JSON wonde= r =E2=80=A6need it for a project. Cannot seem to trace it =E2=80=A6my poor = old eyes are not as good as they used to be =E2=80=A6=F0=9F=98=89

=C2=A0

Cheers TDn

=C2=A0

From: Stuart Tremain [mai= lto:webdna@idfk.com= ..au]
Sent: Tuesday, December 19, 2017 08:19 AM
To:= WebDNA Talk List <t= alk@webdna.us>
Subject: Re: [WebDNA] TCPconnect and Bitcoi= n rate

=C2=A0

OK, thanks.

=C2= =A0

Tom if that was you - nice = job, have been using it for a few years now :)

=

=C2=A0

=C2=A0

Kind rega= rds

=C2=A0

Stuart Tremain

=

Pharoah Lane Software

AUSTRALIA

=C2=A0

=C2=A0

=C2=A0

=C2=A0



On 19 Dec 2017, at 11:15, Mi= chael Davis <ad= min@network13.net> wrote:

=C2=A0

Stuart,=

=C2=A0

<= p class=3D"MsoNormal">I think that was Tom.=C2=A0 He had worked one up prio= r to JSONStore.

= =C2=A0

Mike



= On Dec 18, 2017, at 3:32 PM, Stuart Tremain <webdna@idfk.com.au> wrote:

=C2=A0

Michael

=C2=A0

Were you the person tha= t did the JSON parser some time ago ?

=C2=A0

=C2=A0

Kin= d regards

=C2=A0

Stuart Tremai= n

Pharoah Lane = Software

AUSTRA= LIA

=C2=A0

=C2=A0

=C2=A0

=C2=A0



On 19 De= c 2017, at 10:22, Michael Davis <admin@network13.net> wrote:

=C2=A0

Yariv,

=C2=A0<= /u>

Here's a starting point for yo= u...

=C2=A0

Had to use [middle] to get rid of so= me garbage, which was strange.=C2=A0 Other than that, it should be pretty s= traight forward.

= =C2=A0

=C2=A0

=

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

=C2=A0=



O= n Dec 17, 2017, at 3:54 AM, Office <yariv.n@gmail.com> wrote:

=

=C2=A0

For the last 20 years i never had to receive data from elsewhere till = today.

I need to ask an API fo= r the bitcoin rate

i wan= ted to use the TCPconnect for this but the sample is dead ? :=

=C2=A0

=C2=A0

What i need is a piece of code to get the USD= =E2=80=9Crate" out of this thing (this number: 19,681.9725) so i can = calculate the price of the product to be divided to this to be able to show= the current price in Bitcoin at my store

={"USD":{"code":"USD","symbol":="&#36;","rate":"19,681.9725","d=escription":"United States Dollar","rate_float":19=681.9725}

This is where= it update every second (or less)

=C2=A0

Or any other way to get a rate into = my page :-)

=C2= =A0

Yours,

=C2=A0

Yariv Nachshon

= =C2=A0

=C2=A0

=

=C2=A0



=C2=A0

= =C2=A0


=

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

=C2=A0

=C2=A0

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

=C2=A0

=

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

=C2=A0

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

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

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

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