Skip to content

DocumentModel

SmartJSONEditor edited this page Jan 21, 2019 · 32 revisions

DocumentModel Class

DocumentModel class represents a global application context accessed as "DocumentModel" global variable in script context. DocumentModel let you use Swift JSON Editor application internal helper functions to

  • Retrieve Project Nodes
  • Use helper functions for encoding, logging, timestamp etc.
this.transform = function (inputValue, jsonValue, arrayIndex, parameters, info) {
    var value = DocumentModel.randomValueDatabase("country");
    DocumentModel.log(value);
    return value
}

Logging Functions

Function Description
log Use to print log information about provided objects, prints to console.
error Opens console window and prints passed error text.

Value Transformer Parameter Handling

Function Description
getUserParameterValue Retrive custom stored parameter value
setUserParameterValue Store custom parameter value
removeUserParameterValue Clean up and remove user stored parameter value

Hashing & Encoding

Function Description
base64Encode Encode text in base64 format
base64Decode Decode string from base64 encoded string
urlEncode URL encode string value
urlDecode URL decode string value
getHash Get hash value such md2, md5, sha1, sha512 etc
getHMACHash Get key encrypted hash value such HMAC-MD5, HMAC-SHA1, HMAC-SHA256, HMAC-SHA512 etc
getNonce Get random nonce string

Helper functions

Function Description
randomValueDatabase Retrive randomized value of different type such random country, name etc.

Clone this wiki locally