lib/xml2json.js
function makePath(object, path, index) {
		index = index || 0;
		var obj;

		if (path.length > index + 1) {
			obj = object[path[index]];

			// we always want the last object in an array
			if (_.isArray(obj)) obj = _.last(obj);

			makePath(obj, path, index + 1);
		} else {
			obj = object[path[index]];

			if (!obj) {
				// object doesn't exist yet so make it
				object[path[index]] = {};
			} else {
				if (!_.isArray(obj)) {
					// object isn't an array yet so make an array with the object as the first element
					object[path[index]] = [obj];
				}

				// append the new object
				object[path[index]].push({});
			}
		}
	}
function makePath(object, path, index) {
		index = index || 0;
		var obj;

		if (path.length > index + 1) {
			obj = object[path[index]];

			// we always want the last object in an array
			if (_.isArray(obj)) obj = _.last(obj);

			makePath(obj, path, index + 1);
		} else {
			obj = object[path[index]];

			if (!obj) {
				// object doesn't exist yet so make it
				object[path[index]] = {};
			} else {
				if (!_.isArray(obj)) {
					// object isn't an array yet so make an array with the object as the first element
					object[path[index]] = [obj];
				}

				// append the new object
				object[path[index]].push({});
			}
		}
	}
function makePath ( object , path , index ) { index = index || 0 ; var obj ; if ( path . length > index + 1 ) { obj = object [ path [ index ] ] ; // we always want the last object in an array if ( _ . isArray ( obj ) ) obj = _ . last ( obj ) ; makePath ( obj , path , index + 1 ) ; } else { obj = object [ path [ index ] ] ; if ( ! obj ) { // object doesn't exist yet so make it object [ path [ index ] ] = { } ; } else { if ( ! _ . isArray ( obj ) ) { // object isn't an array yet so make an array with the object as the first element object [ path [ index ] ] = [ obj ] ; } // append the new object object [ path [ index ] ] . push ( { } ) ; } } }
helper function to prepare a path for values this will convert a node into an array if it already exists
helper function to prepare a path for values this will convert a node into an array if it already exists