KB Article 10071
2012/11/27

Close
X
Contact Tech Support

 Email Tech Support
 (250) 655-1766
 [7:30 - 5:00 PST]
Your Meeting ID will be Provided by a Rep.
Tech Support
Tech Support Home
Software Updates
Knowledge Base Search
Recent KB Articles
Product FAQs
Code Samples
Documentation
Tech Blog
System Requirements
Installation Instructions
Support Testimonials
Contact us to...
Create a Ticket
Request a Free Demo
Suggest a New Feature
Submit Feedback
Upload a Large File
Other Services
Software Training
Professional Services

What does the jsonencode function used in Page at a Time (Grid) do?

Product: WebSmart ILE Type: Frequently Asked Question

The `jsonencode` function escapes any special characters that might interfere with valid JSON output and returns the resulting string.

The replacement table below shows which characters are translated to what sequence of text:

CharacterReplacement
\n "\n"
\r "\r"
\ "\\"
" "\""
0x3F (SUB) ""

To read more about JSON, please see the W3Schools JSON Tutorial: http://www.w3schools.com/json/default.asp
For a more technical description of JSON, see the JSON website: http://www.json.org/

Example

Here is an example of this function in use:

crtfld(CustAddr, 30, "A", 0, "Customer Address");
// Assign a value to customer address including a newline.
// The \n in this string is interpreted as a literal newline:
CustAddr = "1234 Fake St\nFakesville, CA";

wrthtml(CustAddr);
// The output to the page (linebreak viewable in the page source) will be:
// 1234 Fake St
// Fakesville, CA

// Escape the string for JSON output
CustAddr = jsonencode(CustAddr);

wrthtml(CustAddr);
// Output to page will be:
// 1234 Fake St\nFakesville, CA

Rate This Article

Did this example help you to achieve your goal?
 Yes  No  Don't Know

Enter additional comments below.   If you want to hear back from us, include your contact information.

Email Address:
Comments:
Please enable JavaScript in order to rate this page.