1Object.assign(
2 {},
3 ...function _flatten(o) {
4 return [].concat(...Object.keys(o)
5 .map(k =>
6 typeof o[k] === 'object' ?
7 _flatten(o[k]) :
8 ({[k]: o[k]})
9 )
10 );
11 }(yourObject)
12)
13
1function dotify(obj) {
2 const res = {};
3 function recurse(obj, current) {
4 for (const key in obj) {
5 const value = obj[key];
6 if(value != undefined) {
7 const newKey = (current ? current + '.' + key : key);
8 if (value && typeof value === 'object') {
9 recurse(value, newKey);
10 } else {
11 res[newKey] = value;
12 }
13 }
14 }
15 }
16 recurse(obj);
17 return res;
18}
19dotify({'a':{'b1':{'c':1},'b2':{'c':1}}}) //{'a.b1.c':1,'a.b2.c':1}