There’s something of some misinformation around exactly what JSON is.
http://timelessrepo.com/json-isnt-a-javascript-subset In any case, the characters encoded for javascript encoding are slightly different than the ones encoded for JSON, thus the need for two encoding routines. JSON doesn’t encode the single-quote because all JSON strings must be double-quoted. This isn’t case for JavaScript which allows for either quote. Robert From: Anthony Humphreys [mailto:[email protected]] Sent: Wednesday, March 25, 2015 4:39 AM To: [email protected] Subject: Re: TeraScript-Talk: Using JSON and KEEP Since JSON is a subset of JavaScript... How/why would encoding="json" be different from encoding="javascript"? Or, would would encoding="json" be an alias for encoding="javascript"? ( Although I do once remember once a bug in encoding="Javascript where it would replace <@CR><@LF> with only \n ) On Tue, Mar 24, 2015 at 9:07 PM, Robert Shubert <[email protected] <mailto:[email protected]> > wrote: The @KEEP is fine except for the " in which case you should use <@DQ>, and I wouldn’t keep any characters greater than 127 (really, these should be converted into Unicode hex, like \u00A1) We just added encoding=json to properly encode JSON strings, it will be available in the 7.1 release. You can create your own JSON encoder (perhaps imperfect, but it should work) with a series of @REPLACE: <@DQ> to \<@DQ> / to \/ <@CHAR 9> to \t <@CHAR 10> to \n <@CHAR 13> to \r \ to \\ (must do this one last) And then you don’t do the encoding=html Robert From: [email protected] <mailto:[email protected]> [mailto:[email protected] <mailto:[email protected]> ] Sent: Tuesday, March 24, 2015 1:04 PM To: [email protected] <mailto:[email protected]> Subject: TeraScript-Talk: Using JSON and KEEP Hi, In one of my TeraScript app I have the following JSON structure to display on a table for export. { "data":[ { "app_id":"appid", "app_number":"12345", "app_question":"<@VAR NAME="question" SCOPE="LOCAL" encoding='html'>", "app_answer":"<@VAR NAME="answer" SCOPE="LOCAL" encoding='html'>", "app_dummy":"" } ]} The "answer" var contains a large block of text with paragraph, quotes, and all other displayable characters and it works fine. But, if the "answer" var contain hidden characters that do not display on any html page, it will fail. I also tried to use the <@KEEP> to keep the normal characters and not picking up the hidden characters and the "answer" var seems to work except it didn't KEEP the quote and any characters using <@CHAR CODE=''> The CHARS='' parameter within my KEEP is as follows: CHARS='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890 -_:;,./!@#$%&*()+=[]{}?|<@CHAR CODE=147><@CHAR CODE=148>\"<@CHAR CODE=10><@CHAR CODE=13><@CHAR CODE=147><@CHAR CODE=148><@SQ>' Please advise me with a better solution in populating the "answer" var for the JSON structure or how to use the <@KEEP> to keep the characters as shown above. Thank you! MC _____ To unsubscribe from this list, please send an email to [email protected] <mailto:[email protected]> with "unsubscribe terascript-talk" in the body. _____ To unsubscribe from this list, please send an email to [email protected] <mailto:[email protected]> with "unsubscribe terascript-talk" in the body. _____ To unsubscribe from this list, please send an email to [email protected] <mailto:[email protected]> with "unsubscribe terascript-talk" in the body. ---------------------------------------- To unsubscribe from this list, please send an email to [email protected] with "unsubscribe terascript-talk" in the body.
