Skip to content

DocumentModel

SmartJSONEditor edited this page Jul 4, 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
  • Retrieve API defined method,url, headers, url parameters or variables
  • 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
getUUID Get random UUID string value

Project Inspection

Function Description
getProjectIdList Retrive project ID Array that is used as a identification parameter in other functions.
getWebViewURLString Retrive project ID identified response webView full URL string
getWebViewURLParameters Retrive project ID identified response webView URL parameter
getResponseString Retrive project ID identified response string (JSON encoded text, simple text or html text)

Helper functions

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