Nantes Paradox Market

    objnest

    5.1.1 • Public • Published

    objnest

    Build Status npm Version JS Standard

    Convert nested object to flatten or expand.

    {foo.bar: 'baz'} <=> {foo: {bar: 'baz'}}

    Installation

    npm install objnest --save

    Usage

    Flatten Object Properties

    Convert nested object into flatten structure.

    'use strict'
    
    const objnest = require('objnest')
    let flattened = objnest.flatten({
        'foo': {'bar': 'baz'}
    })
    console.log(flattened) // => {'foo.bar': 'baz'}

    Expand Object Properties

    Convert flattened object into nested structure.

    'use strict'
    
    const objnest = require('objnest')
    let expanded = objnest.expand({
        'foo.bar': 'baz'
    })
    console.log(expanded) // => {foo: {bar: 'baz'}}

    Tips

    Handling Array

    Brackets with numbers are parsed as array.

    'use strict'
    
    const objnest = require('objnest')
    let flattened = objnest.flatten({
      'foo': { 'bar': [ 'baz0', 'baz1' ] }
    })
    console.log(flattened) // => {'foo.bar[0]': 'baz0', 'foo.bar[1]': 'baz1'}
    'use strict'
    
    const objnest = require('objnest')
    let expanded = objnest.expand({
      'foo.bar[0]': 'baz0',
      'foo.bar[1]': 'baz1'
    })
    console.log(expanded) // => {foo: bar:['baz0', 'baz1']}}

    License

    This software is released under the MIT License.

    Keywords

    Install

    npm i objnest

    DownloadsWeekly Downloads

    3,953

    Version

    5.1.1

    License

    MIT

    Unpacked Size

    73.1 kB

    Total Files

    43

    Last publish

    Collaborators

    • okunishinishi