code: function __toJson(source, template, target) {
    target = target || {};
  
    for (var key in template) {
      var aliases = key.split(",");
      var defaultValue = template[key];
      // using some as a forEach with a 'break'
      aliases.some(function(propName) {
        if (!(propName in source)) return false;
        var value = source[propName];
        // there is a functional property defined with this alias ( not what we want to replace).
        if (typeof value == 'function') return false;
        // '==' is deliberate here - idea is that null or undefined values will never get serialized
        // if default value is set to null.
        if (value == defaultValue) return true;
        if (Array.isArray(value) && value.length === 0) return true;
        if (typeof(defaultValue) === "function") {
          value = defaultValue(value);
        } else if (typeof (value) === "object") {
          if (value && value.parentEnum) {
            value = value.name;
          }
        }
        if (value === undefined) return true;
        target[aliases[0]] = value;
        return true;
      });
    }
    return target;
  }
docs: 'source' is an object that will be transformed into another 'template' is a map where the keys: are the keys to return if a key contains ','s then the key is treated as a delimited string with first of the keys being the key to return and the others all valid aliases for this key 'values' are either 1) the 'default' value of the key 2) a function that takes in the source value and should return the value to set The value from the source is then set on the target, after first passing thru the fn, if provided, UNLESS: 1) it is the default value 2) it is undefined ( nulls WILL be set) 'target' is optional - if it exists then properties of the target will be set ( overwritten if the exist) - if it does not exist then a new object will be created as filled. 'target is returned.