https://github.com/kcmr/get-json-value
Command Line Tool that returns the value of a key path in one or multiple JSON files.
https://github.com/kcmr/get-json-value
cli json
Last synced: 2 months ago
JSON representation
Command Line Tool that returns the value of a key path in one or multiple JSON files.
- Host: GitHub
- URL: https://github.com/kcmr/get-json-value
- Owner: kcmr
- License: mit
- Created: 2019-10-16T18:43:58.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-10-16T18:50:17.000Z (over 6 years ago)
- Last Synced: 2025-03-12T14:50:38.482Z (over 1 year ago)
- Topics: cli, json
- Language: JavaScript
- Size: 3.91 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# get-json-value
> Command Line Tool that returns the value of a key path (`some.key.path`) in one or multiple JSON files.
## Installation
```sh
$ npm i -g get-json-value
```
## Usage
By default it looks for JSON files in the current working directory.
```sh
$ get-json-value (optional file name)
```
## Examples
Executed in a directory with the following files and contents:
```js
locales/
|__es.json // {"home": {"greeting": "Hola"}}
|__en.json // {"home": {"greeting": "Hello"}}
```
It will output:
```sh
$ get-json-value home.greeting
es Hola
en Hello
```
Passing file name (without extension):
```sh
$ 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`.
```json
"scripts": {
"getvalue": "GJV_SEARCH_DIR=./path/to/something npx get-json-value"
}
```
```sh
$ npm run getvalue some.path
```