I'm looking for a way to preserve keys that have .s in to use the same syntax as lodash's set/get.
Ideally something like this:
// Input
{
some: {
'key.with.dots': value
}
}
// Output
{
some['key.with.dots']: value
}
The problem I've found with using the transformKey option is they still get the . joining them.
I have this:
const flatData = flatten(data, {
transformKey: key => (key.includes('.') ? `['${key}']` : key),
});
But the output looks like this. (extra . after some)
{
some.['key.with.dots']: value
}
I'm looking for a way to preserve keys that have
.s in to use the same syntax as lodash's set/get.Ideally something like this:
The problem I've found with using the
transformKeyoption is they still get the.joining them.I have this:
But the output looks like this. (extra
.aftersome)