Re: [WebDNA] TCPconnect and Bitcoin rate

This WebDNA talk-list message is from

2017


It keeps the original formatting.
numero = 113886
interpreted = N
texte = 1486 --Apple-Mail=_E8F0468B-70C3-402A-A327-E0372C446AA1 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 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: >=20 > Hi all, >=20 > Here is the code I use to deal with JSON. >=20 > - Tom >=20 >=20 >=20 > First a function to pull a value when you know what JSON node you = want: >=20 > [!] >=20 >=20 > +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > FUNCTION Name: smGetJsonValue > ** Description: Pull out a value from a JSONobject > ** Input:=20 > jsonObject =3D (the json to be parsed) - required > jsonNode =3D (the node that we the value of) - required > ** usage:=20 > [smGetJsonValue = jsonObject=3D[url][/url]&jsonNode=3D] >=20 > [/!][function name=3DsmGetJsonValue][!] > [/!][text]tReturn=3D[/text][!] >=20 > [/!][text]tJsonObject=3D[/text][!] > [/!][text]tJsonNode=3Dnull[/text][!] >=20 > [/!][showif = [url][params_string][/url]^jsonObject][text]tJsonObject=3D[jsonObject][/te= xt][/showif][!] > [/!][showif = [url][params_string][/url]^jsonNode][text]tJsonNode=3D[jsonNode][/text][/s= howif][!] >=20 > ### Store the jsonObject in a table ### >=20 > [/!][jsonstore table=3DjsonOject][tJsonObject][/jsonstore][!] >=20 > ### Search the table ### >=20 > [/!][search table=3DjsonOject&ne[tJsonNode]data=3Dfind_all][founditems][= !] >=20 > [/!][text]tReturn=3D[interpret][[tJsonNode]][/interpret][/text][!]= >=20 > [/!][/founditems][/search][!] >=20 > ### Return the value ### >=20 > [/!][return][tReturn][/return][!] > [/!][/function] >=20 >=20 >=20 >=20 > Second a Json parser, that's a bit of a hack: >=20 > [text]debug=3DF[/text] >=20 >

Paste some JSON

>

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

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

Sample JSON

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


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

JSON Assigned to Text Variables

> [listvariables name=3Djson-&exact=3DF][name] =3D [value]
> [/listvariables] >=20 > [/showif] >=20 >=20 >=20 > =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 > [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 >=20 > 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 >=20 > =20 >=20 > Cheers TDn >=20 > =C2=A0 <> > From: Stuart Tremain [mailto:webdna@idfk.com.au = ]=20 > Sent: Tuesday, December 19, 2017 08:19 AM > To: WebDNA Talk List > > Subject: Re: [WebDNA] TCPconnect and Bitcoin rate >=20 > =20 >=20 > OK, thanks. >=20 > =20 >=20 > Tom if that was you - nice job, have been using it for a few years now = :) >=20 > =20 >=20 > =20 >=20 > Kind regards >=20 > =20 >=20 > Stuart Tremain >=20 > Pharoah Lane Software >=20 > AUSTRALIA >=20 > webdna@idfk.com.au > =20 >=20 > =20 >=20 > =20 >=20 > =20 >=20 >=20 >=20 >=20 > On 19 Dec 2017, at 11:15, Michael Davis > wrote: >=20 > =20 >=20 > Stuart, >=20 > =20 >=20 > I think that was Tom. He had worked one up prior to JSONStore. >=20 > =20 >=20 > Mike >=20 >=20 >=20 >=20 > On Dec 18, 2017, at 3:32 PM, Stuart Tremain > wrote: >=20 > =20 >=20 > Michael >=20 > =20 >=20 > Were you the person that did the JSON parser some time ago ? >=20 > =20 >=20 > =20 >=20 > Kind regards >=20 > =20 >=20 > Stuart Tremain >=20 > Pharoah Lane Software >=20 > AUSTRALIA >=20 > webdna@idfk.com.au > =20 >=20 > =20 >=20 > =20 >=20 > =20 >=20 >=20 >=20 >=20 > On 19 Dec 2017, at 10:22, Michael Davis > wrote: >=20 > =20 >=20 > Yariv, >=20 > =20 >=20 > Here's a starting point for you... >=20 > =20 >=20 > Had to use [middle] to get rid of some garbage, which was strange. = Other than that, it should be pretty straight forward. >=20 > =20 >=20 > =20 >=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 > =20 >=20 >=20 >=20 >=20 > On Dec 17, 2017, at 3:54 AM, Office > wrote: >=20 > =20 >=20 > For the last 20 years i never had to receive data from elsewhere till = today. >=20 > I need to ask an API for the bitcoin rate >=20 > i wanted to use the TCPconnect for this but the sample is dead ? : >=20 > =20 >=20 > http://www.webdna.us/page.dna?numero=3D264 = > =20 >=20 > 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 >=20 > = {"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) >=20 > https://api.coindesk.com/v1/bpi/currentprice.json = > =20 >=20 > Or any other way to get a rate into my page :-) >=20 > =20 >=20 > Yours, >=20 > =20 >=20 > Yariv Nachshon >=20 > http://www.plonter.co.il > =20 >=20 > =20 >=20 > =20 >=20 >=20 >=20 >=20 > =20 >=20 > =20 >=20 >=20 >=20 >=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 >=20 > =20 >=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 >=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 >=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 > --------------------------------------------------------- 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=_E8F0468B-70C3-402A-A327-E0372C446AA1 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 Hey = Tom

Nice function = :)


Kind regards

Stuart Tremain
Pharoah Lane Software
AUSTRALIA






On 19 Dec 2017, at 20:23, Tom Duke <tom@revolutionaries.ie> 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]<the-json-object>[/url]&jsonNode=3D<the-jso= n-node>]

[/!][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][/te= xt][/showif][!]
[/!][showif = [url][params_string][/url]^jsonNode][text]tJsonNode=3D[jsonNode][/text][/s= howif][!]

= ###  Store the jsonObject in a table =  ###

[/!][jsonstore = table=3DjsonOject][tJsonObject][/jsonstore][!]

###  Search the table =  ###

[/!][search = table=3DjsonOject&ne[tJsonNode]data=3Dfind_all][founditems][!]<= /div>

= [/!][text]tReturn=3D[interpret][[tJsonNode]][/interpret][/text][!]<= /font>

[/!][/founditems][/search][!]

= ###  Return the value  ###

[/!][return][tReturn][/return][!]
[/!][/function]




Second a Json parser, that's a bit of a hack:

[text]debug=3DF[/text]

<h3>Paste = some JSON</h3>
<form action=3D"[thisurl]" = method=3D"post">
<input type=3D"hidden" name=3D"action" = value=3D"parse-json" />
<textarea name=3D"sample-json"= style=3D"width: 50%; height: 200px;" placeholder=3D"paste some = json"></textarea><br />
<button>Parse = me</button>
</form>


[showif [action]=3Dparse-json]

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


[!]


= ------------------------------------
= ###  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][convertchars = 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&trim=3Dboth][convertwords = table=3DjsonSplitConversionsBack][word][/convertwords][/getchars][/grep][/= text][!]
=
= [/!][showif [debug]=3DT][index]. = [url][thisVal][/url]<br />[/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 =  ###

[/!]<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
Digital Revolutionaries
1st Floor, = Castleriver House
14-15 Parliament Street
Temple Bar,Dublin 2
Ireland
----------------------------------------------
[t]: + 353 1 4403907
[e]: <mailto:tom@revolutionaries.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 wonder = =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

 

Cheers TDn

 

From: Stuart Tremain [mailto:webdna@idfk.com.au]
Sent: Tuesday, December 19, 2017 08:19 AM
To: WebDNA Talk List <talk@webdna.us>
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

 

 

 

 



On 19 Dec 2017, at 11:15, Michael = Davis <admin@network13.net> 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 <webdna@idfk.com.au> wrote:

 

Michael

 

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

 

 

Kind regards

 

Stuart Tremain

Pharoah Lane Software

AUSTRALIA

 

 

 

 



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

 

Yariv,

 

Here's a = starting point for you...

 

Had to use [middle] to get rid of some garbage, = which was strange.  Other 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<bitcoin_price.dna>

 



On Dec 17, 2017, at 3:54 AM, Office = <yariv.n@gmail.com> 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 ? :

 

 

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","description":"United States Dollar","rate_float":19681.9725}

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

 

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

 

Yours,

 

Yariv = Nachshon

 

 

 



 

 



--------------------------------------------------------- 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=_E8F0468B-70C3-402A-A327-E0372C446AA1-- . 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)
1486 --Apple-Mail=_E8F0468B-70C3-402A-A327-E0372C446AA1 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 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: >=20 > Hi all, >=20 > Here is the code I use to deal with JSON. >=20 > - Tom >=20 >=20 >=20 > First a function to pull a value when you know what JSON node you = want: >=20 > [!] >=20 >=20 > +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > FUNCTION Name: smGetJsonValue > ** Description: Pull out a value from a JSONobject > ** Input:=20 > jsonObject =3D (the json to be parsed) - required > jsonNode =3D (the node that we the value of) - required > ** usage:=20 > [smGetJsonValue = jsonObject=3D[url][/url]&jsonNode=3D] >=20 > [/!][function name=3DsmGetJsonValue][!] > [/!][text]tReturn=3D[/text][!] >=20 > [/!][text]tJsonObject=3D[/text][!] > [/!][text]tJsonNode=3Dnull[/text][!] >=20 > [/!][showif = [url][params_string][/url]^jsonObject][text]tJsonObject=3D[jsonObject][/te= xt][/showif][!] > [/!][showif = [url][params_string][/url]^jsonNode][text]tJsonNode=3D[jsonNode][/text][/s= howif][!] >=20 > ### Store the jsonObject in a table ### >=20 > [/!][jsonstore table=3DjsonOject][tJsonObject][/jsonstore][!] >=20 > ### Search the table ### >=20 > [/!][search table=3DjsonOject&ne[tJsonNode]data=3Dfind_all][founditems][= !] >=20 > [/!][text]tReturn=3D[interpret][[tJsonNode]][/interpret][/text][!]= >=20 > [/!][/founditems][/search][!] >=20 > ### Return the value ### >=20 > [/!][return][tReturn][/return][!] > [/!][/function] >=20 >=20 >=20 >=20 > Second a Json parser, that's a bit of a hack: >=20 > [text]debug=3DF[/text] >=20 >

Paste some JSON

>

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

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

Sample JSON

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


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

JSON Assigned to Text Variables

> [listvariables name=3Djson-&exact=3DF][name] =3D [value]
> [/listvariables] >=20 > [/showif] >=20 >=20 >=20 > =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 > [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 >=20 > 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 >=20 > =20 >=20 > Cheers TDn >=20 > =C2=A0 <> > From: Stuart Tremain [mailto:webdna@idfk.com.au = ]=20 > Sent: Tuesday, December 19, 2017 08:19 AM > To: WebDNA Talk List > > Subject: Re: [WebDNA] TCPconnect and Bitcoin rate >=20 > =20 >=20 > OK, thanks. >=20 > =20 >=20 > Tom if that was you - nice job, have been using it for a few years now = :) >=20 > =20 >=20 > =20 >=20 > Kind regards >=20 > =20 >=20 > Stuart Tremain >=20 > Pharoah Lane Software >=20 > AUSTRALIA >=20 > webdna@idfk.com.au > =20 >=20 > =20 >=20 > =20 >=20 > =20 >=20 >=20 >=20 >=20 > On 19 Dec 2017, at 11:15, Michael Davis > wrote: >=20 > =20 >=20 > Stuart, >=20 > =20 >=20 > I think that was Tom. He had worked one up prior to JSONStore. >=20 > =20 >=20 > Mike >=20 >=20 >=20 >=20 > On Dec 18, 2017, at 3:32 PM, Stuart Tremain > wrote: >=20 > =20 >=20 > Michael >=20 > =20 >=20 > Were you the person that did the JSON parser some time ago ? >=20 > =20 >=20 > =20 >=20 > Kind regards >=20 > =20 >=20 > Stuart Tremain >=20 > Pharoah Lane Software >=20 > AUSTRALIA >=20 > webdna@idfk.com.au > =20 >=20 > =20 >=20 > =20 >=20 > =20 >=20 >=20 >=20 >=20 > On 19 Dec 2017, at 10:22, Michael Davis > wrote: >=20 > =20 >=20 > Yariv, >=20 > =20 >=20 > Here's a starting point for you... >=20 > =20 >=20 > Had to use [middle] to get rid of some garbage, which was strange. = Other than that, it should be pretty straight forward. >=20 > =20 >=20 > =20 >=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 > =20 >=20 >=20 >=20 >=20 > On Dec 17, 2017, at 3:54 AM, Office > wrote: >=20 > =20 >=20 > For the last 20 years i never had to receive data from elsewhere till = today. >=20 > I need to ask an API for the bitcoin rate >=20 > i wanted to use the TCPconnect for this but the sample is dead ? : >=20 > =20 >=20 > http://www.webdna.us/page.dna?numero=3D264 = > =20 >=20 > 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 >=20 > = {"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) >=20 > https://api.coindesk.com/v1/bpi/currentprice.json = > =20 >=20 > Or any other way to get a rate into my page :-) >=20 > =20 >=20 > Yours, >=20 > =20 >=20 > Yariv Nachshon >=20 > http://www.plonter.co.il > =20 >=20 > =20 >=20 > =20 >=20 >=20 >=20 >=20 > =20 >=20 > =20 >=20 >=20 >=20 >=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 >=20 > =20 >=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 >=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 >=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 > --------------------------------------------------------- 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=_E8F0468B-70C3-402A-A327-E0372C446AA1 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 Hey = Tom

Nice function = :)


Kind regards

Stuart Tremain
Pharoah Lane Software
AUSTRALIA






On 19 Dec 2017, at 20:23, Tom Duke <tom@revolutionaries.ie> 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]<the-json-object>[/url]&jsonNode=3D<the-jso= n-node>]

[/!][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][/te= xt][/showif][!]
[/!][showif = [url][params_string][/url]^jsonNode][text]tJsonNode=3D[jsonNode][/text][/s= howif][!]

= ###  Store the jsonObject in a table =  ###

[/!][jsonstore = table=3DjsonOject][tJsonObject][/jsonstore][!]

###  Search the table =  ###

[/!][search = table=3DjsonOject&ne[tJsonNode]data=3Dfind_all][founditems][!]<= /div>

= [/!][text]tReturn=3D[interpret][[tJsonNode]][/interpret][/text][!]<= /font>

[/!][/founditems][/search][!]

= ###  Return the value  ###

[/!][return][tReturn][/return][!]
[/!][/function]




Second a Json parser, that's a bit of a hack:

[text]debug=3DF[/text]

<h3>Paste = some JSON</h3>
<form action=3D"[thisurl]" = method=3D"post">
<input type=3D"hidden" name=3D"action" = value=3D"parse-json" />
<textarea name=3D"sample-json"= style=3D"width: 50%; height: 200px;" placeholder=3D"paste some = json"></textarea><br />
<button>Parse = me</button>
</form>


[showif [action]=3Dparse-json]

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




= ------------------------------------
= ###  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][convertchars = 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&trim=3Dboth][convertwords = table=3DjsonSplitConversionsBack][word][/convertwords][/getchars][/grep][/= text][!]
=
= [/!][showif [debug]=3DT][index]. = [url][thisVal][/url]<br />[/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 =  ###

[/!]<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
Digital Revolutionaries
1st Floor, = Castleriver House
14-15 Parliament Street
Temple Bar,Dublin 2
Ireland
----------------------------------------------
[t]: + 353 1 4403907
[e]: <mailto:tom@revolutionaries.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 wonder = =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

 

Cheers TDn

 

From: Stuart Tremain [mailto:webdna@idfk.com.au]
Sent: Tuesday, December 19, 2017 08:19 AM
To: WebDNA Talk List <talk@webdna.us>
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

 

 

 

 



On 19 Dec 2017, at 11:15, Michael = Davis <admin@network13.net> 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 <webdna@idfk.com.au> wrote:

 

Michael

 

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

 

 

Kind regards

 

Stuart Tremain

Pharoah Lane Software

AUSTRALIA

 

 

 

 



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

 

Yariv,

 

Here's a = starting point for you...

 

Had to use [middle] to get rid of some garbage, = which was strange.  Other 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<bitcoin_price.dna>

 



On Dec 17, 2017, at 3:54 AM, Office = <yariv.n@gmail.com> 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 ? :

 

 

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","description":"United States Dollar","rate_float":19681.9725}

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

 

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

 

Yours,

 

Yariv = Nachshon

 

 

 



 

 



--------------------------------------------------------- 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=_E8F0468B-70C3-402A-A327-E0372C446AA1-- . Stuart Tremain

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:

Re:What file? (1997) Need help with Shipping/Price discounts (1998) formula.db, adding option prices (1997) Uniqueness of [cart] - revisited (2004) PCS Emailer's role ? (1997) pop up menu's (1998) Bug Report, maybe (1997) Doing VALIDCARD right? (1998) Protecting Realms (1998) Possible Bug in 2.0b15.acgi (1997) WebCatalog2 Feature Feedback (1996) Almost a there but..bye bye NetCloak (1997) Goodbyes (2007) Plugin or CGI or both (1997) Protect vs Authenicate (1997) ShowIf helper? (1998) Error:Too many nested [xxx] contexts (1997) Getting Emailer to send mail (1997) Thanks Grant (1997) WebCat2 Append problem (B14Macacgi) (1997)