lib/json-dry.js
function setPath(obj, keys, value, force) {

	var here,
	    i;

	here = obj;

	for (i = 0; i < keys.length - 1; i++) {

		if (here != null) {
			if (here.hasOwnProperty(keys[i])) {
				here = here[keys[i]];
			} else {
				if (force && here[keys[i]] == null) {
					here[keys[i]] = {};
					here = here[keys[i]];
					continue;
				}

				return null;
			}
		}
	}

	here[keys[keys.length - 1]] = value;
}
function setPath(obj, keys, value, force) {

	var here,
	    i;

	here = obj;

	for (i = 0; i < keys.length - 1; i++) {

		if (here != null) {
			if (here.hasOwnProperty(keys[i])) {
				here = here[keys[i]];
			} else {
				if (force && here[keys[i]] == null) {
					here[keys[i]] = {};
					here = here[keys[i]];
					continue;
				}

				return null;
			}
		}
	}

	here[keys[keys.length - 1]] = value;
}
function setPath ( obj , keys , value , force ) { var here , i ; here = obj ; for ( i = 0 ; i < keys . length - 1 ; i ++ ) { if ( here != null ) { if ( here . hasOwnProperty ( keys [ i ] ) ) { here = here [ keys [ i ] ] ; } else { if ( force && here [ keys [ i ] ] == null ) { here [ keys [ i ] ] = { } ; here = here [ keys [ i ] ] ; continue ; } return null ; } } } here [ keys [ keys . length - 1 ] ] = value ; }
Set something on the given path

@author   Jelle De Loecker   <jelle@develry.be>
@since    1.0.0
@version  1.0.2

@param    {Object}    obj
@param    {Array}     path
@param    {Boolean}   force   If a piece of the path doesn't exist, create it

@return   {Mixed}
Set something on the given path