This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var obj = {}; | |
| function reduce(accum, doc) { | |
| for (var key in doc) { | |
| if (doc.hasOwnProperty(key) && typeof doc[key] !== 'function') { | |
| const type = typeof doc[key] | |
| if (type === 'object') { | |
| const aKey = (accum[key] && typeof accum[key] === 'string') ? key + '_obj' : key | |
| accum[aKey] = accum[aKey] ? accum[aKey] : {} | |
| reduce(accum[aKey], doc[key]) |
OlderNewer