lib/ObjectPaths.js
/**
   * Set the value of the given object at the specified path
   * @param path The path to set the value at
   * @param obj The object to set the value on
   * @param val The value to set
   */
Set the value of the given object at the specified path
@param path The path to set the value at
@param obj The object to set the value on
@param val The value to set
Set the value of the given object at the specified path @param path The path to set the value at @param obj The object to set the value on @param val The value to set
function putPath(path, obj, val) {
    var parts = path.split('.');
    if (parts.length === 1) {
      obj[parts[0]] = val;
    } else {
      var parentPaths = parts.slice(0, parts.length - 1);
      var parent = parentPaths.reduce(function (obj, prop) {
        if (!obj[prop]) {
          if (prop.endsWith(']')) {
            obj[prop] = [];
          } else {
            obj[prop] = {};
          }
          return obj[prop];
        } else {
          if (prop.endsWith(']')) {
            var indMarker = prop.lastIndexOf('[');
            var ind = prop.slice(indMarker + 1, prop.length - 1);
            var arrProp = prop.slice(0, indMarker);
            if (!Array.isArray(obj[arrProp])) obj[arrProp] = [];
            return obj[arrProp][parseInt(ind)];
          } else {
            return obj[prop];
          }
        }
      }, obj);
      if (parent) {
        var prop = parts.slice(-1)[0];
        if (prop.endsWith(']')) {
          var indMarker = prop.lastIndexOf('[');
          var ind = prop.slice(indMarker + 1, prop.length - 1);
          parent[prop.slice(0, indMarker)][ind] = val;
        } else {
          parent[prop] = val;
        }
      } else {
        return parent;
      }
    }
  }
function putPath ( path , obj , val ) { var parts = path . split ( '.' ) ; if ( parts . length === 1 ) { obj [ parts [ 0 ] ] = val ; } else { var parentPaths = parts . slice ( 0 , parts . length - 1 ) ; var parent = parentPaths . reduce ( function ( obj , prop ) { if ( ! obj [ prop ] ) { if ( prop . endsWith ( ']' ) ) { obj [ prop ] = [ ] ; } else { obj [ prop ] = { } ; } return obj [ prop ] ; } else { if ( prop . endsWith ( ']' ) ) { var indMarker = prop . lastIndexOf ( '[' ) ; var ind = prop . slice ( indMarker + 1 , prop . length - 1 ) ; var arrProp = prop . slice ( 0 , indMarker ) ; if ( ! Array . isArray ( obj [ arrProp ] ) ) obj [ arrProp ] = [ ] ; return obj [ arrProp ] [ parseInt ( ind ) ] ; } else { return obj [ prop ] ; } } } , obj ) ; if ( parent ) { var prop = parts . slice ( - 1 ) [ 0 ] ; if ( prop . endsWith ( ']' ) ) { var indMarker = prop . lastIndexOf ( '[' ) ; var ind = prop . slice ( indMarker + 1 , prop . length - 1 ) ; parent [ prop . slice ( 0 , indMarker ) ] [ ind ] = val ; } else { parent [ prop ] = val ; } } else { return parent ; } } }
Set the value of the given object at the specified path
 @param path The path to set the value at
 @param obj The object to set the value on
 @param val The value to set
Set the value of the given object at the specified path @param path The path to set the value at @param obj The object to set the value on @param val The value to set