/objectpathlist

Converts an JS object to an object pathlist and back

Primary LanguageJavaScriptMIT LicenseMIT

objectpathlist

Converts an JS object to an object pathlist and back

Usage

npm install --save objectpathlist

test.json:

{
    "one": 1,
    "two": 2, 
    "object": {
        "child": {
            "another": "key"
        }
    },
    "array": [
        1,
        2,
        3, 
        {
            "test": "foo",
            "bar": "baz",
            "float": 0.1
        }
    ]
}

some.js:

var objectpathlist = require('objectpathlist');
objectpathlist.toPathlist(JSONDATA); // to convert object to pathlist
objectpathlist.toObject(PATHLIST); // to convert pathlist (back) to object

example pathlist from test.json:

{ 
    one: 1,
    two: 2,
    'object.child.another': 'key',
    'array.0': 1,
    'array.1': 2,
    'array.2': 3,
    'array.3.test': 'foo',
    'array.3.bar': 'baz',
    'array.3.float': 0.1 
 }