jsonpathdecoder
TypeScript icon, indicating that this package has built-in type declarations

1.0.6 • Public • Published

JSONPathDecoder

JSONPathDecoder is a library designed to help you easily parse lengthy json config files, or just any json at all

Installation

npm i jsonpathdeocder

Normal Usage

const jpd = require('jsonpathdecoder');
let testObject = {
    "accounts" : [
        {
            "name" : "Jared",
            "email" : "jared@npm.org"
        },

        {
            "name" : "Archie",
            "email" : "archie@littlehouseontheprarie.com"
        }
    ]
}

let returnValue = jpd.decode(testObject,'accounts.name');

// OUTPUT: ["Jared", "Archie"]

Array Usage

const jpd = require('jsonpathdecoder');
let testObject = {
    "accounts" : [
        {
            "name" : "Jared",
            "email" : "jared@npm.org"
        },

        {
            "name" : "Archie",
            "email" : "archie@littlehouseontheprarie.com"
        }
    ]
}

let returnValue = jpd.decode(testObject,'accounts.0');

// OUTPUT: {
                "name" : "Jared",
                "email" : "jared@npm.org"
            }

Regex Usage

const jpd = require('jsonpathdecoder');
let testObject = {
    "accounts" : [
        {
            "name" : "Jared",
            "email" : "jared@npm.org"
        },

        {
            "name" : "Archie",
            "email" : "archie@littlehouseontheprarie.com"
        }
    ]
}

let returnValue = jpd.decode(testObject,'accounts./n.*/');

// OUTPUT: ["Jared", "Archie"]

Readme

Keywords

none

Package Sidebar

Install

npm i jsonpathdecoder

Weekly Downloads

1

Version

1.0.6

License

ISC

Unpacked Size

18.4 kB

Total Files

19

Last publish

Collaborators

  • curiousfrog