That action/tag does still exist. However, due to changes in v7 (notably being 
64-bit) the engine was changed. JS wasn’t working at all in 7.0.1. In 7.0.3 we 
fixed the tag but left the action disabled on 64-bit Windows. The tag no longer 
interacts with the server object either, so the response of of the JS tag would 
need to be TML that could be executed to create the array. I believe the JS 
execution would be faster than the code I posted yesterday, but be somewhat 
more awkward to implement.



All of this will be sorted out and imporved in v8.



Robert



From: Anthony Humphreys [mailto:anth...@humphreys.org]
Sent: Thursday, April 14, 2016 2:24 AM
To: TeraScript-Talk@terascript.com
Subject: RE: TeraScript-Talk: Best way to parse JSON objects



Back in the day, I'd use the built-in JS action, and use JSON2.JS to parse JSON 
objects, and then pass back to Tango what I needed with the sever object's set 
variable.
Does TeraScript still have a JS action or JS tag?

On Apr 13, 2016 19:25, "Robert Shubert" <rshub...@tronics.com 
<mailto:rshub...@tronics.com> > wrote:

Dave,



TS 7 doesn’t have a JSON parser built-in. It’s something we can support in 8 
because we have nested collections.



I whipped up a simple JSON parser, which is attached. It’s just a block of TML 
that you can adapt. It’s not very powerful and won’t support nested objects 
(because TS 7 wouldn’t allow that easily) and won’t handle arrays (just not 
supported)



It does handle quoting, as in your example, as well as \-escaped characters and 
numbers. Note that it does not handle the \uXXXX hex encoding either.



Let me know if you have any questions. Or need help improving the code. Or find 
a bug.



Oh, it also won’t be very fast, so large strings will take time.



I left your test string (with some additions) in the file so you can see it 
work. It will also attempt to realize when the parsing failed and throw an 
error – although this is very simple right now.



Robert



From: Dave Machin [mailto:dave.mac...@incontact.com 
<mailto:dave.mac...@incontact.com> ]
Sent: Wednesday, April 13, 2016 2:13 PM
To: TeraScript-Talk@terascript.com <mailto:TeraScript-Talk@terascript.com>
Subject: TeraScript-Talk: Best way to parse JSON objects



I’m trying to figure out the most efficient way to parse JSON objects and can’t 
seem to think of a simple method.



The <@tokenize> tag seems to get me close but doesn’t fully work.



For example,



If I have this JSON data, where there is a comma in the “name” value:



<@assign request$test_json value='{"name":"Johnson, John","street":"Oslo West 
16","phone":"555 1234567"}'>



And I then do this:



<@tokenize value=<@var request$test_json> CDELIM=":" RDELIM=",">



I end up with this:




{"name"

"Johnson


John"



"street"

"Oslo West 16"


"phone"

"555 1234567"}



So the comma in their name is causing trouble.



Is there some kind of best-practice way of parsing JSON data with WiTango?  
We’re on version 7.0.7 currently.



Thanks

Dave Machin




  ­­



  _____

To unsubscribe from this list, please send an email to lists...@terascript.com 
<mailto:lists...@terascript.com>  with "unsubscribe terascript-talk" in the 
body.



  _____

To unsubscribe from this list, please send an email to lists...@terascript.com 
<mailto:lists...@terascript.com>  with "unsubscribe terascript-talk" in the 
body.



  _____

To unsubscribe from this list, please send an email to lists...@terascript.com 
<mailto:lists...@terascript.com>  with "unsubscribe terascript-talk" in the 
body.




----------------------------------------

To unsubscribe from this list, please send an email to lists...@terascript.com 
with "unsubscribe terascript-talk" in the body.

Reply via email to