get-json-value

1.0.0 • Public • Published

get-json-value

Command Line Tool that returns the value of a key path (some.key.path) in one or multiple JSON files.

Installation

$ npm i -g get-json-value

Usage

By default it looks for JSON files in the current working directory.

$ get-json-value <object.key.path> <file> (optional file name)

Examples

Executed in a directory with the following files and contents:

locales/
|__es.json // {"home": {"greeting": "Hola"}}
|__en.json // {"home": {"greeting": "Hello"}}

It will output:

$ get-json-value home.greeting
 
es Hola
en Hello

Passing file name (without extension):

$ get-json-value home.greeting es
 
es Hola

Custom search directory

You can specify a custom search directory, for instance, for usage in npm-scripts, by setting the Node env variable GJV_SEARCH_DIR.

"scripts"{
  "getvalue": "GJV_SEARCH_DIR=./path/to/something npx get-json-value"
}
$ npm run getvalue some.path

/get-json-value/

    Package Sidebar

    Install

    npm i get-json-value

    Weekly Downloads

    4

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    3.77 kB

    Total Files

    4

    Last publish

    Collaborators

    • kuscamara