Tags:
create new tag
, view all tags

EmbeddedJSPlugin API

This page lists all the API functions for EmbeddedJSPlugin. See also EJS Table API List.

print

print("text"[, "text" ...]);

Appends output texts. Multiple arguments are appended altogether. If non-string objects are given, JSON.stringify() is automatically used to serialize the data.

println

println("text"[, "text" ...]);

Appends output texts in the same way as print(), followed by a line break at the end.

requireTopic

requireTopic("[Web.]Topic");
requireTopic({web: "Web", topic: "Topic"});

Executes the topic content as EJS. A topic is loaded only once even when used multiple times. It should usually be used to load JavaScript libraries.

An exception is thrown if the topic does not exist or if the VIEW permission is denied.

findWebs

var webNames = findWebs("Web*");
var webNames = findWebs({web: "Web*"});
var formattedNames = findWebs("Web*", function (webName, loop) {});
var formattedNames = findWebs({web: "Web*", callback: function (webName, loop) {}});

Returns an array of web names that are matched with a pattern with wildcards.

findTopics

var topicNames = findTopics("[Web*.]Topic*");
var topicNames = findTopics({web: "Web*", topic: "Topic*"});
var formattedNames = findTopics("[Web*.]Topic*", function (topicName, loop) {});
var formattedNames = findTopics({web: "Web*", topic: "Topic*", callback: function (topicName, loop) {}});

Returns an array of topic names that are matched with a pattern with wildcards. The web name can also include wildcards.

If a web name is specified, the returned topic names will contain the web name prefix.

For example:

findTopics('TestTopic*'); // returns ['TestTopic1', 'TestTopic2']
findTopics('WebA.TestTopic*'); // returns ['WebA.TestTopic1', 'WebA.TestTopic2']
findTopics('Web*.TestTopic*'); // returns ['WebA.TestTopic1', 'WebA.TestTopic2', 'WebB.TestTopic1', 'WebB.TestTopic2']

webExists

var exists = webExists("Web");
var exists = webExists({web: "Web"});

Determines if the web exists.

topicExists

var exists = topicExists("[Web.]Topic");
var exists = topicExists({web: "Web", topic: "Topic"});

Determines if the topic exists.

createWeb

createWeb("%WEB%/SubWeb");
createWeb("%WEB%/SubWeb", {baseWeb: "TemplateWeb"});
createWeb({web: "%WEB%/SubWeb", baseWeb: "TemplateWeb"});

Creates a new web or subweb. Because of the default same-web policy, this API is usually used to create a subweb rather than a top-level web.

If the baseWeb parameter is given, the new web is copied from the baseWeb. Otherwise, the baseWeb defaults to the configured value ($TWiki::cfg{EmbeddedJSPlugin}{DefaultBaseWeb}).

An exception is thrown if the web does not exist or if the CREATEWEB permission is denied.

See also Save Action Policies.

moveWeb

moveWeb("%WEB%/SubWeb1", "%WEB%/SubWeb2");
moveWeb({web: "%WEB%/SubWeb1", toWeb: "%WEB%/SubWeb2"});

Renames a web or subweb, or moves it to another web or subweb.

An exception is thrown if the web does not exist or if the RENAMEWEB permission is denied.

Note: Links are not automatically updated.

See also Save Action Policies.

removeWeb

removeWeb("%WEB%/SubWeb");
removeWeb("%WEB%/SubWeb", {toWeb: "%TRASHWEB%/SubWeb"});
removeWeb({web: "%WEB%/SubWeb", toWeb: "%TRASHWEB%/SubWeb"});

Removes a web or subweb. The target web will be moved to the trash web, rather than permanently deleted.

An exception is thrown if the web does not exist or if the RENAMEWEB permission is denied.

See also Save Action Policies.

readTopic

var topicText = readTopic("[Web.]Topic");
var topicText = readTopic("[Web.]Topic", {rev: revisionNumber});
var topicText = readTopic({web: "Web", topic: "Topic", rev: revisionNumber});

Returns the topic content.

An exception is thrown if the topic does not exist or if the VIEW permission is denied.

saveTopic

saveTopic("[Web.]Topic", "TopicText");
saveTopic("[Web.]Topic", "TopicText", {forceNewRevision: true, minor: true, breakLock: true, parentTopic: "ParenTopic"});
saveTopic({web: "Web", topic: "Topic", text: "TopicText", forceNewRevision: true, minor: true, breakLock: true, parentTopic: "ParentTopic"});

Saves the topic content. If the topic does not exist, a new topic is created.

An exception is thrown if the specified web does not exist or if the CHANGE permission is denied.

Additional parameter(s) can be specified as below:

Parameter Value
forceNewRevision Force the revision to be incremented, even when the revision number should otherwise stay the same.
minor Suppress notification (similarly to checkpoint or quietsave).
breakLock Ignore the edit lock acquired by another user.
parentTopic Set the parent topic name. If the value is either undefined, null, "", or "none", then the parent topic will be unset.
formName Set the form name (same as setFormName())
FormFieldName Form field name/value pairs can be specified to update the values (same as setFormField())

See also Save Action Policies.

moveTopic

moveTopic("[FromWeb.]FromTopic", "[ToWeb.]ToTopic");
moveTopic("[FromWeb.]FromTopic", "[ToWeb.]ToTopic", {breakLock: true});
moveTopic({web: "FromWeb", topic: "FromTopic", toWeb: "ToWeb", toTopic: "ToTopic", breakLock: true});

Renames the topic or moves it to another web.

An exception is thrown if the topic does not exist or if the CHANGE permission is denied.

Additional parameter(s) can be specified as below:

Parameter Value
breakLock Ignore the edit lock acquired by another user.

See also Save Action Policies.

removeTopic

removeTopic("[Web.]Topic");
removeTopic("[Web.]Topic", {toTopic: "ToTopic"});
removeTopic({web: "Web", topic: "Topic", toWeb: "%TRASHWEB%", toTopic: "ToTopic"});

Removes a topic. The target topic will be moved to the trash web, rather than permanently deleted.

An exception is thrown if the topic does not exist or if the CHANGE permission is denied.

See also Save Action Policies.

getFormName

var formName = getFormName("[Web.]Topic");
var formName = getFormName("[Web.]Topic", {rev: revisionNumber});
var formName = getFormName({web: "Web", topic: "Topic", rev: revisionNumber});

Retrieves the form name of the topic.

An exception is thrown if the topic does not exist or if the VIEW permission is denied.

setFormName

setFormName("[Web.]Topic", "ExampleForm");
setFormName({web: "Web", topic: "Topic", name: "ExampleForm"});

Saves the topic with the new form name.

An exception is thrown if the topic does not exist or if the CHANGE permission is denied.

The call of this function will eventually invoke the same logic as saveTopic() so the same parameters are accepted.

See also Save Action Policies.

getFormField

var fieldValue = getFormField("[Web.]Topic", "FieldName");
var fieldValue = getFormField("[Web.]Topic", "FieldName", {rev: revisionNumber});
var fieldValue = getFormField({web: "Web", topic: "Topic", name: "FieldName", rev: revisionNumber});

Retrieves the form field value of the topic.

An exception is thrown if the topic does not exist or if the VIEW permission is denied.

setFormField

setFormField(["Web.]Topic", "FieldName", "FieldValue");
setFormField({web: "Web", topic: "Topic", name: "FieldName", value: "FieldValue"});

Saves the topic with the new form field name/value pair(s).

An exception is thrown if the topic does not exist or if the CHANGE permission is denied.

The call of this function will eventually invoke the same logic as saveTopic() so the same parameters are accepted. If multiple fields are to be set, it is more efficient to use saveTopic() to set all the fields at the same time.

See also Save Action Policies.

getFormFields

var fields = getFormFields("[Web.]Topic");
var fields = getFormFields("[Web.]Topic", {rev: revisionNumber});
var fields = getFormFields({web: "Web", topic: "Topic", rev: revisionNumber});

Retrieves all the form fields of the topic. The return value is an object of field/value pairs.

An exception is thrown if the topic does not exist or if the VIEW permission is denied.

checkPermission

var allowed = checkPermission("[Web.]Topic", "VIEW"); // or "CHANGE"
var allowed = checkPermission({web: "Web", topic: "Topic", type: "VIEW"}); // or "CHANGE"

Determines if the specified permission type is allowed for the topic.

An exception is thrown if the topic does not exist.

getRevisionInfo

var revisionInfo = getRevisionInfo("[Web.]Topic");
var revisionInfo = getRevisionInfo("[Web.]Topic", {rev: revisionNumber});
var revisionInfo = getRevisionInfo({web: "Web", topic: "Topic", rev: revisionNumber});

Retrieves the revision information.

An exception is thrown if the topic does not exist or if the VIEW permission is denied.

Return Value Description
revisionInfo.rev Revision number, such as 1, 2, 3, ...
revisionInfo.time Unix timestamp
revisionInfo.user User name stored in the revision management system
revisionInfo.userName Converted user name, retrieved by getUserName()

See also Date/Time Values.

getRevisionAtTime

var revisionNumber = getRevisionAtTime("[Web.]Topic", unixTimestamp);
var revisionNumber = getRevisionAtTime({web: "Web", topic: "Topic", time: unixTimestamp});

Retrieves the revision number at the specified Unix timestamp.

An exception is thrown if the topic does not exist or if the VIEW permission is denied.

See also Date/Time Values.

getEditLock

var editLock = getEditLock("[Web.]Topic");
var editLock = getEditLock({web: "Web", topic: "Topic"});

Retrieves the edit lock (a.k.a. lease file) of the topic. Returns undefined if there are no lease files.

An exception is thrown if the topic does not exist or if the VIEW permission is denied.

Return Value Description
editLock.user The user name stored in the lease file
editLock.userName Converted user name, retrieved by getUserName()
editLock.conflict A string indicating a lock conflict ("lease_active" or "lease_old"); or an empty string if no conflicts
editLock.taken Unix timestamp at which the lock was taken
editLock.expires Unix timestamp at which the lock is to expire

See also Date/Time Values.

acquireEditLock

acquireEditLock("[Web.]Topic");
acquireEditLock({web: "Web", topic: "Topic"});

Acquires the edit lock (a.k.a. lease file) to prevent other users from editing the same topic.

An exception is thrown if there is a lease conflict with another user, if the topic does not exist or if the CHANGE permission is denied.

releaseEditLock

releaseEditLock("[Web.]Topic");
releaseEditLock({web: "Web", topic: "Topic"});

Releases the edit lock acquired by the current user if any. If there is an edit lock acquired by another user, the lease file is left unchanged.

An exception is thrown if the topic does not exist.

getAttachmentList

var fileNames = getAttachmentList("[Web.]Topic");
var fileNames = getAttachmentList({web: "Web", topic: "Topic"});

Returns an array of attachment names of the topic.

An exception is thrown if the topic does not exist or if the VIEW permission is denied.

attachmentExists

var exists = attachmentExists("[Web.]Topic", "FileName.txt");
var exists = attachmentExists({web: "Web", topic: "Topic", file: "FileName.txt"});

Determines if the attachment exists.

readAttachment

var contentText = readAttachment("[Web.]Topic", "FileName.txt");
var contentText = readAttachment("[Web.]Topic", "FileName.txt", {rev: fileRevisionNumber});
var contentText = readAttachment({web: "Web", topic: "Topic", file: "FileName.txt", rev: fileRevisionNumber});

Retrieves the attachment file content.

An exception is thrown if the attachment does not exist or if the VIEW permission is denied.

saveAttachment

saveAttachment("[Web.]Topic", "FileName.txt", "CataText");
saveAttachment({web: "Web", topic: "Topic", file: "FileName.txt", data: "CataText"});

Saves the attachment file content. If the attachment does not exist, a new attachment is created.

An exceptiton is thrown if the topic does not exist or if the CHANGE permission is denied.

See also Save Action Policies.

moveAttachment

moveAttachment("[FromWeb.]FromTopic", "FromFileName.txt", "[ToWeb.]ToTopic", "ToFileName.txt");
moveAttachment({web: "FromWeb", topic: "FromTopic", file: "FromFileName.txt", toWeb: "ToWeb", toTopic: "ToTopic", toFile: "ToFileName.txt"});

Renames the attachment or moves it to another topic.

An exception is thrown if the attachment does not exist or if the CHANGE permission is denied.

See also Save Action Policies.

removeAttachment

removeTopic("[Web.]Topic", "FileName.txt");
removeTopic({web: "Web", topic: "Topic", file: "FileName.txt", toWeb: "%TRASHWEB%", toTopic: "ToTopic", toFile: "ToFileName.txt"});

Removes an attachment. The target attachment will be moved to the TrashAttachment topic in the trash web, rather than permanently deleted.

An exception is thrown if the attachment does not exist or if the CHANGE permission is denied.

See also Save Action Policies.

getMethod

var method = getMethod(); // "GET" or "POST"

Retrieves the current HTTP request method.

isPost

var condition = isPost();

Determines if the current HTTP request method is POST.

getParam

var paramValue = getParam("ParamName");
var paramValue = getParam("ParamName", "DefaultValue");
var paramValue = getParam({name: "ParamName", default: "DefaultValue"});

Retrieves the URL parameter value (GET) or form-data value (POST).

setParam

setParam("ParamName", "ParamValue");
setParam({name: "ParamName", value: "ParamValue"});

Sets the URL parameter value (GET) or form-data value (POST) for later use in the session. It affects the actual usage of %URLPARAM{...}% in the TWiki markup after EJS preprocessing is done.

getUserName

var userName = getUserName();
var userName = getUserName("someUserName");
var userName = getUserName({user: "someUserName"});

Retrieves the current user name if there are no arguments.

If the argument is given, it is converted to the canonical or login user name.

getWikiName

var wikiName = getWikiName();
var wikiName = getWikiName("someUserName");
var wikiName = getWikiName({user: "someUserName"});

Retrieves the current user's wiki name (such as UserFoobar) if there are no arguments.

If the argument is given, it is converted to the user's wiki name.

getWikiUserName

var wikiUserName = getWikiUserName();
var wikiUserName = getWikiUserName("someUserName");
var wikiUserName = getWikiUserName({user: "someUserName"});

Retrieves the current user's wiki user name (such as Main.UserFoobar) if there are no arguments.

If the argument is given, it is converted to the user's wiki user name.

getVariable

var variableValue = getVariable("VARIABLE_NAME"[, {param: value, ...}]);

Retrieves the value of the TWiki variable (%VARIABLE%).

Optionally, parameters can be specified as key/value pairs (%VARIABLE{param="value"}%). The default parameter is passed as _DEFAULT key (%VARIABLE{"The default value"}%).

setVariable

setVariable("VARIABLE_NAME", "VariableValue");

Sets the value of the TWiki variable (%VARIABLE%) for later use. It affects the actual usage of %VARIABLE% in the TWiki markup after EJS preprocessing is done.

expandVariables

var expandedText = expandVariables("%FOO% %BAR% %BAZ{...}%");

Expands all the occurrences of the TWiki variables (%VARIABLE%).

expandAutoInc

var newTopicName = expandAutoInc("TopicNameAUTOINC001");

Replaces the AUTOINC pattern in a topic name with the next number to make a new (non-existing) topic name.

formatText

var formatedText = formatText("$foo $bar $baz", {foo: "Foo", bar: "Bar", baz: "Baz"});

Converts the variable names in the $variable format, where the values are replaced by the given key/value pairs. The standard escape variables (such as $percnt and $dollar) are also expanded. Non-existing variable names are ignored, and the $variable will appear in the result string.

isTrue

var condition = isTrue("on/off");
var condition = isTrue("on/off", "default");

Determines if the given text is a true value. If it is either "off", "false" or "no", then the value is regarded as false. If is it undefined or null, the default value is used instead.

normalizeWebTopicName

var nameInfo = normalizeWebTopicName('[Web.]Topic');
var nameInfo = normalizeWebTopicName('Web', 'Topic');
var nameInfo = normalizeWebTopicName({web: 'Web', topic: 'Topic'});

Normalizes the web name and topic name.

Return Value Description
nameInfo.web Normalized web name
nameInfo.topic Normalized topic name

escapeHTML

var escapedText = escapeHTML("< unescaped >");

Converts special HTML characters (such as < and >) into HTML entity strings (such as &lt; and &gt;).

unescapeHTML

var unescapedText = unescapeHTML("&lt; escaped &gt;");

Converts HTML entity strings (such as &lt; and &gt;) into the original HTML characters (such as < and >).

escapeQuote

var escapedText = escapeQuote("\"unescaped\" text\n");

Escapes special characters so that the text can be embedded in the JSON or JavaScript string notation.

unescapeQuote

var unescapedText = unescapeQuote("\\\"escaped\\\" text\\n");

Unescapes special characters that are escaped by escapeQuote().

escapeTable

var escapedText = escapeTable("unescaped || text");

Escapes special characters so that the text can be embedded in the TWiki table notation. Special HTML characters are also converted to HTML entity strings.

unescapeTable

var unescapedText = unescapeTable("escaped %VBAR%%VBAR% text");

Unescapes special characters that are escaped by escapeTable(). HTML entity strings are also converted to the original HTML characters.

parseTable

var table = parseTable("| *A* | *B* |\n" + "| 1 | 2 |\n" + "| 3 | 4 |\n");
var table = parseTable("| 1 | 2 |\n" + "| 3 | 4 |\n", {header: false});
var table = parseTable("| 1 | 2 |\n" + "| 3 | 4 |\n", {header: false, fields: ['Field1', 'Field2']});
var table = parseTable(readTopic("ManyTables"), {target: 2});
var table = parseTable({text: "| *A* | *B* |\n" + "| 1 | 2 |\n" + "| 3 | 4 |\n"});
var table = parseTable(..., function (row, loop) {});
var table = parseTable({text: "...", header: false, fields: [...], target: 2, callback: function (row, loop) {}});

Parses a TWiki table notation.

Argument Parameter Default Value Description
header true Indicates the parsed table has a header row.
fields (none) Specifies an array of field names. If there is already a header row in the parsed table, this parameter will override the field names used in the return value.
target 1 Select a table by number (starting from 1) out of multiple tables in the input text.
callback (none) Callback function per row. Each row argument can be an object of field/value pairs or a simple array, depending on the context.

The return value is an object containing fields and rows if the fields are detected from the input or specified as an argument. If there are no available fields, the return value is simply an array of arrays.

Return Value Description
table.fields Array of field names
table.rows Array of rows, each of which is an object of field/value pairs

By default, the first row is assumed to be a header, and the values are detected as fields. If the header parameter is set to false, the first row is not parsed as a header.

If the fields parameter is given, the fields used as the keys of each row object are overridden regardless of the first row.

If a callback function is given, each row can be altered by returning an updated row object, or excluded by returning nothing (undefined or null).

When the input text contains multiple tables, the first table is parsed by default. If the target parameter is given, the table at the specified number is detected (starting from 1).

All the values are converted by unescapeTable().

See also Table API for example code.

formatTable

var formatedText = formatTable(table);
var formatedText = formatTable(table, {header: false});
var formatedText = formatTable(table, function (row, loop) {});
var formatedText = formatTable({fields: [...], rows: [...], header: false, callback: function (row, loop) {}});

Builds a TWiki table notation from an object representing a table.

Argument Parameter Default Value Description
fields (none) Array of field names
rows (none) Array of rows, each of which is an object of field/value pairs
header true Indicates the header row is prepended to the result table.
callback (none) Callback function per row. Each row argument can be an object of field/value pairs or a simple array, depending on the context.

The structure of the table parameter (first argument) roughly corresponds to the return value of parseTable(), either an object with fields and rows or an array of arrays.

By default, the first row is prepended as a header based on the fields values. If the header parameter is set to false or if there are no fields, the header row is not prepended.

If a callback function is given, each row can be altered by returning an updated row object, or excluded by returning nothing (undefined or null).

All the values are converted by escapeTable().

Because of how this API works, it can also be used to generate a single row of a table:

formatTable([['Foo', 'Bar', 'Baz']]);
// returns "| Foo | Bar | Baz |"

formatTable({fields: ['Foo', 'Bar', 'Baz']});
// returns "| *Foo* | *Bar* | *Baz* |"

See also Table API for example code.

parseCSV

var table = parseCSV("A,B,C\n1,2,3\n4,5,6");
var table = parseCSV("1,2,3\n4,5,6", {header: false});
var table = parseCSV("1,2,3\n4,5,6", {header: false, fields: ['Field1', 'Field2', 'Field3']});
var table = parseCSV({text: "A,B,C\n1,2,3\n4,5,6"});
var table = parseCSV(..., function (row, loop) {});
var table = parseCSV({text: "...", header: false, fields: [...], callback: function (row, loop) {}});

Parses a CSV format. The input parameters and the return value are similar to parseTable().

See also Table API for example code.

formatCSV

var formatedText = formatCSV(table);
var formatedText = formatCSV(table, {header: false});
var formatedText = formatCSV(table, function (row, loop) {});
var formatedText = formatCSV({fields: [...], rows: [...], header: false, callback: function (row, loop) {}});

Builds a CSV text from an object representing a table. The input object and the parameters are similar to formatTable().

See also Table API for example code.

getExternalResource

var response = getExternalResource('http://...');
var response = getExternalResource('http://...', {headers: [], method: ...});
var response = getExternalResource('http://...', {headers: {}, method: ...);

Sends an HTTP GET request to the specified URL and receives the response.

Argument Parameter Description
headers HTTP request headers
method Overrides HTTP request method (Default: "GET"/"POST")
timeout Sets timeout in seconds
maxRedirect Limits the number of HTTP redirect
insecureSSL Indicates whether to ignore SSL hostname verification (Default: false)

The request header format can be in either array or object. The header names are case-insensitive.

  • Array: ['Header-1', 'Value 1', 'Header-2', 'Value 2', ...]
  • Object: {'Header-1': 'Value 1', 'Header-2': 'Value 2', ...}

The return value is an HTTP response object containing the following values:

Return Value Description
response.code HTTP response code (e.g. 200)
response.message HTTP response status message (e.g. "OK")
response.headers HTTP response header object
response.content Response body content
response.isSuccess Indicates if the response is a success (2xx)
response.isRedirect Indicates if the response is an HTTP redirect (3xx)
response.isError Indicates if the response is an error (4xx or greater)

The response header object is the name/value pairs, where the case is normalized to how RFC describes (e.g. "Content-Type") and the value is either a single string or an array if there are two or more occurrences in the HTTP response.

postExternalResource

var response = postExternalResource('http://...', 'Request Body Content');
var response = postExternalResource('http://...', 'Request Body Content', {headers: [], method: ...});
var response = postExternalResource('http://...', 'Request Body Content', {headers: [], method: ...});

Sends an HTTP POST request with a request body content to the specified URL and receives the response.

The argument values and the return value are similar to getExternalResource(), except that the request method defaults to "POST".

captureOutput

var captured = captureOutput(function () {
    print("Captured Text");
});
var captured = captureOutput(callbackWithArgs, arg1, arg2, ...);

Stores all the outputs in the callback function as a result of print(), instead of actually printing the texts.

Optionally, if additional arguments are given, the callback function will be invoked with those arguments.

This is useful when suppressing the output of a function that would otherwise print something. It can also be used to modify the output before actually printing it.

Since texts outside of the EJS tags (<%...%>) are also printed, inline texts can be captured as a string as below:

<%
var text = captureOutput(function () {
%>
| *Foo* | *Bar* |
| 100 | 200 |
<%
});
var table = parseTable(text);
%>

It is also possible to nest the call within another callback.

var outer = captureOutput(function () {
    print("Foo");
    var inner = captureOutput(function () {
        print("Bar");
    });
    print("Baz");
});
// outer == "FooBaz"
// inner == "Bar"

getJavaScriptEngine

var engineName = getJavaScriptEngine();

Retrieves the underlying JavaScript engine name, such as JE and JavaScript::V8.

getEJSConfig

var config = getEJSConfig();

Retrieves the EmbeddedJSPlugin configuration under the current execution context.

Return Value Description
config.namespace Namespace for EmbeddedJSPlugin API functions. Default: undefined
config.postMethodPolicy POST method policy
config.sameWebPolicy Same-web policy
config.timeout Timeout in seconds
config.defaultBaseWeb Default template web name used for createWeb() API

The context may be affected by the system configurations ($TWiki::cfg), the preference variables (such as EJS_NAMESPACE), and the parameters passed to %EJS_INCLUDE{...}%.

executeEJS

executeEJS('Text containing EJS tags');
executeEJS('Text containing EJS tags', {var1: "Value 1", var2: "Value 2", ...});

Executes the given text as EJS in the inline context just like the JavaScript eval() function.

Additional variables can be passed via the second argument.

console

console.log("message");
console.debug("message");
console.info("message");
console.warn("message");
console.error("message");

These methods are equivalent to invoking the following code, where the outputs are inserted into the browser-side console.

<script>console.log(...);</script>

The argument is serialized by JSON.stringify(), so non-string objects can also be examined in the console.

JSON

var object = JSON.parse("{\"key\": \"value\"}");
var jsonText = JSON.stringify({key: "value"});

Converts a JSON string into a JavaScript value, and vice versa.

Topic revision: r1 - 2017-08-24 - MahiroAndo
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.