dot-expand

Expand key-value pairs whose keys use dot-notation

Usage no npm install needed!

<script type="module">
  import dotExpand from 'https://cdn.skypack.dev/dot-expand';
</script>

README

dot-expand

Installation

Expand key-value pairs whose keys are in dot notation (.e.g, users.name) into objects.

npm i dot-expand --save

yarn add dot-expand

Example

import expand from 'dot-expand'

const pojo = expand({
  'users.df01d9e5.name': 'Tom',
  'users.df01d9e5.age': 37
})

// => { users: { df01d9e5: { name: 'Tom', age: 37 } } }