Skip to content

Latest commit

 

History

History
33 lines (24 loc) · 1.79 KB

SwiftJSONEditor-JavascriptContextController.md

File metadata and controls

33 lines (24 loc) · 1.79 KB

JavascriptContextController Class (sje)

JavascriptContextController class represents a global application context accessed as "sje". Context let you use Swift JSON Editor application internal helper functions to

  • Retrive Project Nodes
  • Insert new Project Nodes
  • Use helper functions for encoding, logging etc.

Functions

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];
  		// Use JavascriptContextController via sje global object
      	sje.log(item);
	}
}

Call sje global object to invoke JavascriptContextController functions.