Skip to content

Latest commit

 

History

History
70 lines (43 loc) · 1.96 KB

README.md

File metadata and controls

70 lines (43 loc) · 1.96 KB

obj-unflatten PayPal Version Downloads Get help on Codementor

Convert flatten objects in nested ones.

☁️ Installation

$ npm i --save obj-unflatten

📋 Example

const unflatten = require("obj-unflatten");

console.log(unflatten({
    "name.first": "Johnny"
  , "name.last": "B."
  , age: 20
}));
// { name: { first: 'Johnny', last: 'B.' }, age: 20 }

// Custom separator
console.log(unflatten({
    "name-first": "Johnny"
  , "name-last": "B."
  , age: 20
}, "-"));
// { name: { first: 'Johnny', last: 'B.' }, age: 20 }

📝 Documentation

unflattenObject(flatten, separator)

Convert flatten objects in nested ones.

Params

  • Object flatten: The flatten object that should be converted.
  • Object separator: The field separator (default: ".").

Return

  • Object Unflatten object

😋 How to contribute

Have an idea? Found a bug? See how to contribute.

✨ Related

  • obj-flatten – Convert nested objects in flatten ones.

📜 License

MIT © Ionică Bizău