End $.fn.SPServices.SPXmlToJson
12146
function attrToJson(v, objectType) {
        function identity(x) { return x; }

        var result = {

            /* Generic [Reusable] Functions */
            "Integer": intToJsonObject,
            "Number": floatToJsonObject,
            "Boolean": booleanToJsonObject,
            "DateTime": dateToJsonObject,
            "User": userToJsonObject,
            "UserMulti": userMultiToJsonObject,
            "Lookup": lookupToJsonObject,
            "lookupMulti": lookupMultiToJsonObject,
            "MultiChoice": choiceMultiToJsonObject,
            "Calculated": calcToJsonObject,
            "Attachments": attachmentsToJsonObject,
            "URL": urlToJsonObject,
            "JSON": jsonToJsonObject, // Special case for text JSON stored in text columns

            /* These objectTypes reuse above functions */
            "Text": result.Default,
            "Counter": result.Integer,
            "datetime": result.DateTime,    // For calculated columns, stored as datetime;#value
            "AllDayEvent": result.Boolean,
            "Recurrence": result.Boolean,
            "Currency": result.Number,
            "float": result.Number, // For calculated columns, stored as float;#value
            "RelatedItems": result.JSON,

            "Default": identity
        };

        return (result[objectType] || identity)(v);

/*
        switch (objectType) {

            case "Text":
                colValue = v;
                break;
            case "DateTime":
            case "datetime": // For calculated columns, stored as datetime;#value
                // Dates have dashes instead of slashes: ows_Created="2009-08-25 14:24:48"
                colValue = dateToJsonObject(v);
                break;
            case "User":
                colValue = userToJsonObject(v);
                break;
            case "UserMulti":
                colValue = userMultiToJsonObject(v);
                break;
            case "Lookup":
                colValue = lookupToJsonObject(v);
                break;

            case "LookupMulti":
                colValue = lookupMultiToJsonObject(v);
                break;
            case "Boolean":
            case "AllDayEvent":
            case "Recurrence":
                colValue = booleanToJsonObject(v);
                break;

            case "Integer":
                colValue = intToJsonObject(v);
                break;

            case "Counter":
                colValue = intToJsonObject(v);
                break;

            case "MultiChoice":
                colValue = choiceMultiToJsonObject(v);
                break;
            case "Number":
            case "Currency":
            case "float": // For calculated columns, stored as float;#value
                colValue = floatToJsonObject(v);
                break;
            case "Calculated":
                colValue = calcToJsonObject(v);
                break;
            case "Attachments":
                colValue = attachmentsToJsonObject(v);
                break;
            case "URL":
                colValue = urlToJsonObject(v);
                break;
            case "JSON":
            case "RelatedItems":
                colValue = jsonToJsonObject(v); // Special case for text JSON stored in text columns
                break;

            default:
                // All other objectTypes will be simple strings
                colValue = v;
                break;
        }
        return colValue;
 */
    }
579030
function join() {
    var pagelet = this
      , result = this._queue.map(function flatten(fragment) {
          if (!fragment.name || !fragment.view) return '';
          return fragment.view;
        });

    try {
      result = this._contentType === contentTypes.json
        ? JSON.stringify(result.shift())
        : result.join('');
    } catch (error) {
      this.emit('done', error);
      return this.debug('Captured error while stringifying JSON data %s', error);
    }

    this._queue.length = 0;
    return result;
  }
989624
public void finishJson(final Object obj) {
        this.contentType = this.jsonContentType;
        if (this.recycleListener != null) this.output = obj;
        finish(request.getJsonConvert().convertTo(getBodyBufferSupplier(), obj));
    }
459917
function ToJSON(jsonName) {
        if (jsonName === 'result') jsonName = 'default';
        let args = Array.prototype.slice.call(arguments);
        if (typeof jsonName === 'undefined') {
          jsonName = 'default';
        } else if (typeof jsonName === 'string') {
          args.splice(0, 1);  //remove the name.
        }
        let jsonFn = modelObj.jsons[jsonName],
          result = this.dataValues;
        if (typeof jsonFn === 'undefined' && jsonName !== 'default') { // silent fallback
          if (typeof modelObj.jsons['default'] === 'function') {
            result = modelObj.jsons['default'].apply(this, args);
          }
        } else {
          if (typeof modelObj.jsons[jsonName] === 'function') {
            result = modelObj.jsons[jsonName].apply(this, args);
          } else {
            result = this.dataValues;
          }
        }
        if (result === this) {
          result = this.dataValues;
        }
        if (typeof result === 'object' && result != null) {
          for (let i = 0; i < modelObj.privateAttributes.length; i++) {
            if (typeof result[modelObj.privateAttributes[i]] !== 'undefined') {
              delete result[modelObj.privateAttributes[i]];
            }
          }
        }
        return result;
      }
548031
function oldJson(json, local, namePrefix){
  if (namePrefix) {
    utils.assertString(namePrefix, 'namePrefix');
    namePrefix = namePrefix.val;
  } else {
    namePrefix = '';
  }
  local = local ? local.toBoolean() : new nodes.Boolean(local);
  var scope = local.isTrue ? this.currentScope : this.global.scope;

  convert(json);
  return;

  function convert(obj, prefix){
    prefix = prefix ? prefix + '-' : '';
    for (var key in obj){
      var val = obj[key];
      var name = prefix + key;
      if ('object' == typeof val) {
        convert(val, name);
      } else {
        val = utils.coerce(val);
        if ('string' == val.nodeName) val = utils.parseString(val.string);
        scope.add({ name: namePrefix + name, val: val });
      }
    }
  }
}
853905
function parser (content, options, fn) {
      var jshintrc = path.join(process.env.HOME || process.env.USERPROFILE, '.jshintrc')
        , jshintninja = configurator(jshintrc)
        , config = options.jshint;

      // extend all the things
      config = _.extend(config, jshintninja);

      canihaz.jshint(function lazyload (err, jshint) {
        if (err) return fn(err);

        var validates = jshint.JSHINT(content, config)
          , errors;

        if (!validates) errors = formatters.js(jshint.JSHINT.errors);
        fn(null, errors);
      });
    }
326488
async function exportCustomSelectorsToJsonFile(to, customSelectors) {
	const jsonContent = JSON.stringify({
		'custom-selectors': customSelectors
	}, null, '  ');
	const json = `${jsonContent}\n`;

	await writeFile(to, json);
}
1090367
function readXmlAsJson(filePath, simplify) {
  var xmlData;
  var parsedData;
  var parserOptions = {};

  if (simplify) {
    parserOptions = {
      attrValueProcessors: [xml2jsProcessors.parseNumbers, xml2jsProcessors.parseBooleans],
      explicitArray: false,
      mergeAttrs: true,
      explicitRoot: false
    };
  }

  var xmlParser = new xml2js.Parser(parserOptions);
  try {
    xmlData = fs.readFileSync(filePath);
    xmlParser.parseString(xmlData, function(err, data) {
      if (data) {
        parsedData = data;
      }
    });
  } catch (err) {}

  return parsedData;
}
70037
function writeClientLibXml(item, options) {
    var content = '<?xml version="1.0" encoding="UTF-8"?>' +
        '<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"' +
        ' jcr:primaryType="cq:ClientLibraryFolder"';

    if (item.hasOwnProperty('categories')) {
        var fieldValue = item.categories.join(',');
        content += ' categories="[' + fieldValue + ']"';
    } else {
        content += ' categories="[' + item.name + ']" ';
    }

    clientLibDirectoryFields.forEach(function (fieldKey) {
      if (item.hasOwnProperty(fieldKey)) {
          if (typeof item[fieldKey] === 'boolean') {
            // Boolean value
            content += ' ' + fieldKey + '="{Boolean}' + item[fieldKey] + '"';
          } else if (Array.isArray(item[fieldKey])) {
            // Array of strings
            var fieldValue = item[fieldKey].join(',');
            content += ' ' + fieldKey + '="[' + fieldValue + ']"';
          } else if (typeof item[fieldKey] === 'string') {
            // String value
            content += ' ' + fieldKey + '="' + item[fieldKey] + '"';
          }
      }
    });

    content += "/>";
    var outputPath = item.outputPath || path.join(item.path, item.name);
    var contentXml = path.join(outputPath + "/.content.xml");

    options.verbose && console.log("write clientlib json file: " + contentXml);

    fse.writeFileSync(contentXml, content);
}
416600
function() {
      var t = this,
          sbJSON = t.sidebar.toJSON({deep:true, trim:true});

      // Function to trim closed sub-branches from a tree
      var trimSubBranch = function(tree) {
        var branches = tree.branches;
        for (var i in branches) {
          var subTree = branches[i];
          if (subTree.isOpen && !subTree.isLoading) {
            branches[i] = trimSubBranch(subTree);
          } else {
            branches[i] = {
              id: subTree.id,
            };
            if (subTree.label) {
              branches[i].label = subTree.label;
            }
          }
        }
        return tree;
      };

      // Trim sub-tree elements in pages, and save
      for (var i = 0; i < sbJSON.tree.branches.length; i++) {
        sbJSON.tree.branches[i] = trimSubBranch(sbJSON.tree.branches[i]);
      }
      localStorage.sidebar = JSON.stringify(sbJSON);
    }
714625
@SuppressWarnings("unchecked")
    public void finishJson(final JsonConvert convert, final CompletableFuture future) {
        finish(convert, (Type) null, future);
    }
944259
function processXsd() {
	console.log();
	console.log('Processing XML schema...');
	var src = x2j.xml2json(xsdStr,{"attributePrefix": "@","valueProperty": false, "coerceTypes": false});
	var obj = xsd.getJsonSchema(src,'nitro-schema','',true);

	console.log('Validating generated JSON schema...');
	var validate = ajv.compile(jsonSchema);
	validate(obj);
	var errors = validate.errors;
	if (errors) {
		console.log(errors);
		return false;
	}
	else {
		fs.writeFileSync('./nitroApi/nitro-schema.yaml',yaml.safeDump(obj),'utf8');

		var existing = openapi.components.schemas;
		var root = obj.properties;
		openapi.components.schemas = obj.definitions;
		openapi.components.schemas.nitro = root.nitro;
		openapi.components.schemas.nitro.additionalProperties = true; // cope with undefined 'items'
		openapi.components.schemas.ErrorModel = existing.ErrorModel;
		recurse(openapi.components.schemas,{},function(obj,key,state){
			if ((key === '$ref') && (typeof obj.$ref === 'string') && (obj.$ref.startsWith('#/definitions/'))) {
				obj.$ref = obj.$ref.replace('#/definitions/','#/components/schemas/');
			}
		});

		return true;
	}
}
213432
function formatToJsonXMLString(changes, shallow) {
            var properties = [];

            var diff = changes.value;
            if (changes.changed == 'equal') {
                return $sce.trustAsHtml(inspect(diff, shallow));
            }

            for (var key in diff) {
                properties.push(formatChange(key, diff[key], shallow));
            }

            return $sce.trustAsHtml('<span>' + openChar + '</span>\n<div class="diff-level">' + properties.join('<span>,</span>\n') + '\n</div><span>' + closeChar + '</span>');

        }
318137
function() {
		let obj = {}, 
			key = null, 		// property key
			extended = false, 	// whether the is extended Mark object or legacy JSON object
			index = 0;
		
		let putText = function(text) {
			// check preceding node
			if (index > 0 && typeof obj[index-1] === 'string') {
				// merge with previous text
				obj[index-1] += text;
			} else {
				Object.defineProperty(obj, index, {value:text, writable:true, configurable:true}); // make content non-enumerable
				index++;
			}
		},
		parseContent = function() {
			while (ch) {
				if (ch === '{' || ch === '(' || ch === '[' && text[at] === '#') { // child object
					let child = (ch === '(') ? pragma(obj) : (ch === '[' ? binary(obj):object(obj));  
					Object.defineProperty(obj, index, {value:child, writable:true, configurable:true}); // make content non-enumerable
					// all 4 types: Mark object, JSON object, Mark pragma, Mark binary store reference to parent 
					child[$parent] = obj;  index++;  
				}
				else if (ch === '"' || ch === "'") { // text node
					let str = string();
					// only output non empty text
					if (str) putText(str);
				}
				else if (ch === '}') { 
					next();  obj[$length] = index;
					return;
				}
				else {
					error(UNEXPECT_CHAR + renderChar(ch));
				}
				white();
			}
			error(UNEXPECT_END);		
		};
		
		next();  white();  // skip the starting '{'
		while (ch) {
			if (ch === '}') { // end of the object
				next();  
				if (extended) { obj[$length] = index; }
				return obj;   // could be empty object
			}
			// scan the key
			if (ch === '{' || ch === '(' || ch === '[') { // child object, pragma or binary
				if (extended) {
					parseContent();  return obj;
				}
				error(UNEXPECT_CHAR + "'"+ ch +"'");
			}
			if (ch === '"' || ch === "'") { // quoted key
				var str = string();  white();
				if (ch === ':') { // property or JSON object
					key = str;
				} else {
					if (extended) { // already got type name
						// only output non-empty text
						if (str) putText(str);
						parseContent();  return obj;
					}
					else if (!key) { // at the starting of the object
						// create the object
						obj = MARK(str, null, null);
						extended = true;  // key = str;
						continue;							
					}
					else { 
						error(UNEXPECT_CHAR + renderChar(ch));
					}
				}
			}
			else { // if (ch==='_' || ch==='$' || 'a'<=ch && ch<='z' || 'A'<=ch && ch<='Z')
				// Mark unquoted key, which needs to be valid JS identifier.
				var ident = identifier();  white();
				if (ch == ':') { // property value
					key = ident;
				} else {
					if (!extended) { // start of Mark object
						obj = MARK(ident, null, null);
						extended = true;  // key = ident;
						continue;
					}
					error(UNEXPECT_CHAR + renderChar(ch));
				}
			}
			
			// key-value pair
			next(); // skip ':'
			var val = value();
			if (extended && !isNaN(key*1)) { // any numeric key is rejected for Mark object
				error("Numeric key not allowed as Mark property name");
			}
			if (obj[key] && typeof obj[key] !== 'function') {
				error("Duplicate key not allowed: " + key);
			}
			obj[key] = val;  white();
			// ',' is optional in Mark
			if (ch === ',') {
				next();  white();
			} 
		}
		error(UNEXPECT_END);
	}
605715
function jsTreeCtrl() {
        /*jshint validthis:true */
        var nodeSerialId = 1;
        var vm = this;

        vm.nodesFingerprint = function (e) {
            if (!e.__uiNodeId) {
                e.__uiNodeId = nodeSerialId++;
            }
            return '' + e.__uiNodeId + (e.id || '') + (e.text || '') + (e.type || '');
        };

        vm.changeWatcher = function (arraySource, tokenFn) {
            var self;
            var getTokens = function () {
                var result = [], token, el;
                if (arraySource) {
                    var array = angular.isFunction(arraySource) ? arraySource() : arraySource;
                    for (var i = 0, n = array.length; i < n; i++) {
                        el = array[i];
                        token = tokenFn(el);
                        map[token] = el;
                        result.push(token);
                    }
                }
                return result;
            };
            // returns elements in that are in a but not in b
            // subtractAsSets([4, 5, 6], [4, 5, 7]) => [6]
            var subtractAsSets = function (a, b) {
                var result = [], inB = {}, i, n;
                for (i = 0, n = b.length; i < n; i++) {
                    inB[b[i]] = true;
                }
                for (i = 0, n = a.length; i < n; i++) {
                    if (!inB[a[i]]) {
                        result.push(a[i]);
                    }
                }
                return result;
            };

            // Map objects to tokens and vice-versa
            var map = {};

            var applyChanges = function (newTokens, oldTokens) {
                var i, n, el, token;
                var replacedTokens = {};
                var removedTokens = subtractAsSets(oldTokens, newTokens);
                for (i = 0, n = removedTokens.length; i < n; i++) {
                    var removedToken = removedTokens[i];
                    el = map[removedToken];
                    delete map[removedToken];
                    var newToken = tokenFn(el);
                    // if the element wasn't removed but simply got a new token, its old token will be different from the current one
                    if (newToken === removedToken) {
                        self.onRemoved(el);
                    } else {
                        replacedTokens[newToken] = removedToken;
                        self.onChanged(el);
                    }
                }

                var addedTokens = subtractAsSets(newTokens, oldTokens);
                for (i = 0, n = addedTokens.length; i < n; i++) {
                    token = addedTokens[i];
                    el = map[token];
                    if (!replacedTokens[token]) {
                        self.onAdded(el);
                    }
                }

            };
            self = {
                subscribe: function (scope, onChanged) {
                    scope.$watch(getTokens, function (newTokens, oldTokens) {
                        if (!onChanged || onChanged(newTokens, oldTokens) !== false) {
                            applyChanges(newTokens, oldTokens);
                        }
                    }, true);
                },
                onAdded: angular.noop,
                onChanged: angular.noop,
                onRemoved: angular.noop
            };
            return self;
        };
    }
57763
function toJSON() {
    var s = this;
    var values = Object.assign({}, s.schema);
    Object.keys(values).forEach(function (key) {
      var isFunc = iftype.isFunction(values[key]);

      if (isFunc) {
        delete values[key];
      }
    });
    return values;
  }
1065029
function (oData, sFileType) {
				// code extension and properties files do not need formation
				if ((sFileType === "js") || (sFileType === "properties")) {
					return oData;
				}
				// other files should be formatted to JSON
				try {
					oData = JSON.parse(oData);
					return JSON.stringify(oData, null, '\t');
				} catch (oError){
					var ErrorUtils = sap.ui.require("sap/ui/fl/support/apps/contentbrowser/utils/ErrorUtils");
					ErrorUtils.displayError("Error", oError.name, oError.message);
					return oData;
				}
			}