此函数使用您指定的参数应添加/更新
obj容器中的数据。请注意,您需要跟踪
obj架构中的哪些元素是容器,哪些是值(字符串,整数等),否则您将开始引发异常。
obj = {}; // global objectfunction set(path, value) { var schema = obj; // a moving reference to internal objects within obj var pList = path.split('.'); var len = pList.length; for(var i = 0; i < len-1; i++) { var elem = pList[i]; if( !schema[elem] ) schema[elem] = {} schema = schema[elem]; } schema[pList[len-1]] = value;}set('mongo.db.user', 'root');


