Repository navigation
DocumentModel
Development edited this page Jul 8, 2017
·
2 revisions
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
- Retrive Project Nodes
- Insert new Project Nodes
- Use helper functions for encoding, logging, timestamp etc.
| Function | Parameters | Returns | Description |
|---|---|---|---|
| log(object) | Javascript/String/Number | String description | Use to print log information about provided objects |
| newProjectModel(projectNodeID) | String (project node identifier) or nil | creates and returns new child model project node as JavascriptProjectNode object | if you pass nil context will append to document root, if you pass projectNodeIdentifier, new child node will be appended. |
| newProjectFolder(projectNodeID) | String (project node identifier) or nil | creates and returns new child folder project node as JavascriptProjectNode object | if you pass nil context will append to document root, if you pass projectNodeIdentifier, new child node will be appended. |
| rootJsonNode(projectNodeID) | String (project node identifier) or nil | root JSON node associated with project node as JavascriptJsonNode object | returns root json node of project node |
Example:
var sjeTreeNode = function (rootJsonNode, selectedJsonNodes) {
var filtered = rootJsonNode.jsonPath("$.store.book[*].author");
for (var i = 0; i < filtered.length; i++) {
var item = filtered[i];
DocumentModel.log(item);
}
}Call DocumentModel global object to invoke helper functions.