Sometimes you need to blow out a JavaScript object so that the keys are fully qualified. For example, if you are doing a rest query on some third party database, or to represent a more than 1 level deep object in a two dimension space like a spreadsheet.

The problem

Your object looks like this
but you need it to look like this


The code

First – we need to flatten it, so we get this
and we also need to join the resultant keys with dots.

and finally, put it all together to make a new object with the flattened keys


For more on this snippets, see: