function encode(obj, key){
  var newKey = null;

  if(key[0] === "$"){
    newKey = $ + key;
  }

  if(key.includes(".")){
    newKey = (newKey || key).split(".").join(DOT);
  }

  if(newKey){
    obj[newKey] = obj[key];
    delete obj[key]
  }
}
encodes object keys starting with "$"
or containing "."

@param obj object containing suspect key
@param key key to encode