What is WebDNA

WebDNA is a scripting and database system designed to easily build web applications.

WebDNA and BioType

BioType service is a biometric keystroke dynamic system. It will be part of WebDNA 8.5

Download WebDNA

Download WebDNA freeware, try it and register later if you want.

WebDNA resources

The list of all WebDNA instructions.
WebDNA
Software Corporation
Search WebDNA Site
 Menu


HOME


DOWNLOADS


LEARN


EDUCATION


NEWS


COMMUNITY


STORE


SUPPORT


CONTACT

Re: [WebDNA] JSON Parser

This WebDNA talk-list message is from

2014


It keeps the original formatting.
numero = 111115
interpreted = N
texte = --Apple-Mail=_248101A9-7E38-40DB-A6E1-143F1CFCA417 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Very nice Tom !! I spent yesterday morning getting a service to provide XML rather than = JSON - your solution comes 1 day late but a nice one to have in the code = locker :) Regards Stuart Tremain IDFK Web Developments AUSTRALIA webdna@idfk.com.au On 21 Feb 2014, at 9:57 am, Donovan Brooke wrote: > nice Tom!, > I briefly used: > http://json.org/example.html >=20 > seems to work well. >=20 > Donovan >=20 >=20 > =20 >> --- Original message ---=20 >> Subject: [WebDNA] JSON Parser=20 >> From: Tom Duke =20 >> To: talk@webdna.us =20 >> Date: Thursday, 20/02/2014 4:48 PM >>=20 >> Hi all, >>=20 >> There has been talk on the list in the past about a JSON parser. I = have knocked together a cheap and nasty parser which tries to assign all = of the key:value pairs to WebDNA variables. You can try it here: >>=20 >> https://www.revolutionaries.ie/admin/test-json.tmpl >>=20 >> It doesn't properly parse the JSON but it might help someone. The = code is below. >>=20 >> - Tom >>=20 >>=20 >>=20 >>=20 >> [text]debug=3DF[/text] >>=20 >>

Paste some JSON

>>

(some samples here http://www.jq= uery4u.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] >> --------------------------------------------------------- This = message is sent to you because you are subscribed to the mailing list = . To unsubscribe, E-mail to: = archives: = http://mail.webdna.us/list/talk@webdna.us Bug Reporting: = support@webdna.us >=20 > --------------------------------------------------------- This message = is sent to you because you are subscribed to the mailing list . To = unsubscribe, E-mail to:archives: = http://mail.webdna.us/list/talk@webdna.us Bug Reporting: = support@webdna.us --Apple-Mail=_248101A9-7E38-40DB-A6E1-143F1CFCA417 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii Very = nice Tom !!

I spent yesterday morning getting a = service to provide XML rather than JSON - your solution comes 1 day late = but a nice one to have in the code locker = :)


Regards

Stuart = Tremain
IDFK Web Developments
AUSTRALIA




On 21 Feb 2014, at 9:57 am, Donovan Brooke <dbrooke@webdna.us> = wrote:

nice Tom!,
I briefly used:
http://json.org/example.html
=
seems to work = well.

Donovan


 
--- Original message --- 
Subject: [WebDNA] JSON Parser 
From: Tom Duke <tom@revolutionaries.ie> 
To: talk@webdna.us <talk@webdna.us> 
Date: Thursday, 20/02/2014 4:48 = PM

Hi all,

There has been talk on the = list in the past about a JSON parser.  I have knocked together a = cheap and nasty parser which tries to assign all of the key:value pairs = to WebDNA variables.   You can try it = here:


It = doesn't properly parse the JSON but it might help someone.   The = code is below.

- = Tom




=
[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][!]
<= div>

------------------------------------
###  pass two - add = bar to just before each key:value pair = ###

[/!][text]theJson=3D[grep = search=3D("[^"]*"):&replace=3D|\1=3D][theJson][/grep][/text][!]
<= div>

------------------------------------
###  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]
<= /div>
--------------------------------------------------------- = 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://mail.webdna.us/l= ist/talk@webdna.us Bug Reporting: support@webdna.us

--= ------------------------------------------------------- This message is = sent to you because you are subscribed to the mailing list . To = unsubscribe, E-mail to:archives: http://mail.webdna.us/l= ist/talk@webdna.us Bug Reporting: support@webdna.us

= --Apple-Mail=_248101A9-7E38-40DB-A6E1-143F1CFCA417-- Associated Messages, from the most recent to the oldest:

    
  1. Re: [WebDNA] JSON Parser (David Bastedo 2014)
  2. Re: [WebDNA] JSON Parser (Tom Duke 2014)
  3. Re: [WebDNA] JSON Parser (David Bastedo 2014)
  4. Re: [WebDNA] JSON Parser (Stuart Tremain 2014)
  5. Re: [WebDNA] JSON Parser (Donovan Brooke 2014)
  6. [WebDNA] JSON Parser (Tom Duke 2014)
--Apple-Mail=_248101A9-7E38-40DB-A6E1-143F1CFCA417 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Very nice Tom !! I spent yesterday morning getting a service to provide XML rather than = JSON - your solution comes 1 day late but a nice one to have in the code = locker :) Regards Stuart Tremain IDFK Web Developments AUSTRALIA webdna@idfk.com.au On 21 Feb 2014, at 9:57 am, Donovan Brooke wrote: > nice Tom!, > I briefly used: > http://json.org/example.html >=20 > seems to work well. >=20 > Donovan >=20 >=20 > =20 >> --- Original message ---=20 >> Subject: [WebDNA] JSON Parser=20 >> From: Tom Duke =20 >> To: talk@webdna.us =20 >> Date: Thursday, 20/02/2014 4:48 PM >>=20 >> Hi all, >>=20 >> There has been talk on the list in the past about a JSON parser. I = have knocked together a cheap and nasty parser which tries to assign all = of the key:value pairs to WebDNA variables. You can try it here: >>=20 >> https://www.revolutionaries.ie/admin/test-json.tmpl >>=20 >> It doesn't properly parse the JSON but it might help someone. The = code is below. >>=20 >> - Tom >>=20 >>=20 >>=20 >>=20 >> [text]debug=3DF[/text] >>=20 >>

Paste some JSON

>>

(some samples here http://www.jq= uery4u.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] >> --------------------------------------------------------- This = message is sent to you because you are subscribed to the mailing list = . To unsubscribe, E-mail to: = archives: = http://mail.webdna.us/list/talk@webdna.us Bug Reporting: = support@webdna.us >=20 > --------------------------------------------------------- This message = is sent to you because you are subscribed to the mailing list . To = unsubscribe, E-mail to:archives: = http://mail.webdna.us/list/talk@webdna.us Bug Reporting: = support@webdna.us --Apple-Mail=_248101A9-7E38-40DB-A6E1-143F1CFCA417 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii Very = nice Tom !!

I spent yesterday morning getting a = service to provide XML rather than JSON - your solution comes 1 day late = but a nice one to have in the code locker = :)


Regards

Stuart = Tremain
IDFK Web Developments
AUSTRALIA




On 21 Feb 2014, at 9:57 am, Donovan Brooke <dbrooke@webdna.us> = wrote:

nice Tom!,
I briefly used:
http://json.org/example.html
=
seems to work = well.

Donovan


 
--- Original message --- 
Subject: [WebDNA] JSON Parser 
From: Tom Duke <tom@revolutionaries.ie> 
To: talk@webdna.us <talk@webdna.us> 
Date: Thursday, 20/02/2014 4:48 = PM

Hi all,

There has been talk on the = list in the past about a JSON parser.  I have knocked together a = cheap and nasty parser which tries to assign all of the key:value pairs = to WebDNA variables.   You can try it = here:


It = doesn't properly parse the JSON but it might help someone.   The = code is below.

- = Tom




=
[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][!]
<= div>

------------------------------------
###  pass two - add = bar to just before each key:value pair = ###

[/!][text]theJson=3D[grep = search=3D("[^"]*"):&replace=3D|\1=3D][theJson][/grep][/text][!]
<= div>

------------------------------------
###  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]
<= /div>
--------------------------------------------------------- = 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://mail.webdna.us/l= ist/talk@webdna.us Bug Reporting: support@webdna.us

--= ------------------------------------------------------- This message is = sent to you because you are subscribed to the mailing list . To = unsubscribe, E-mail to:archives: http://mail.webdna.us/l= ist/talk@webdna.us Bug Reporting: support@webdna.us

= --Apple-Mail=_248101A9-7E38-40DB-A6E1-143F1CFCA417-- 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:

Just Testing (1997) carriage returns in data (1997) Whats wrong with this code? (1998) Payments -> Bank Accounts (2005) Public beta 6 for WebCatalog 4.0 is now available (2000) New public beta available (1997) Change in Host? (1999) Universal db access template ... (2002) Bad cookie (1998) Bug Report, maybe (1997) RAM variables (1997) Database Structure? (1998) [WebDNA] Don't change [ipaddress] ... (2015) Generating and appending SKU to a db automatically (1998) WebCommerce: Folder organization ? (1997) TRAINING videos - Prove IT. (1998) OT: Microsoft to buy Macromedia? (2002) Cold Fusion Buster (1997) Webcatalog server support (1997) Country & Ship-to address & other fields ? (1997)