Skip to content
This repository has been archived by the owner on Dec 31, 2019. It is now read-only.

AkashBabu/flatenize-object

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Deprecated in favor of flat

flattenize-object

A Nodejs Library to flattenize an object within another object

Installation

npm install flattenize-object --save

Usage

var flattenize = require('flattenize-object');
var obj = {
  "a": 1,
  "b": {
    "c": [
      2,
      3,
      4,
      5
    ],
    "d": 1,
    "e": "string",
    "inObj": {
      "f": 123,
      "g": [
        1,
        2,
        3
      ]
    }
  }
}

console.log(JSON.stringify(flatten(obj, 'b.inObj')));

{
  "a": 1,
  "b": {
    "c": [
      2,
      3,
      4,
      5
    ],
    "d": 1,
    "e": "string",
    "f": 123,
    "g": [
      1,
      2,
      3
    ]
  }
}

console.log(JSON.stringify(flatten(obj, 'b'), undefined, 2));

{
  "a": 1,
  "c": [
    2,
    3,
    4,
    5
  ],
  "d": 1,
  "e": "string",
  "f": 123,
  "g": [
    1,
    2,
    3
  ]
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published