@lafferty-lounge/json

0.1.3 • Public • Published

@lafferty-lounge/json

The json-ll utility lets you easily inspect, merge, modify, and export JSON and yaml

Installation

npm install -g @lafferty-lounge/json

Usage

json-ll [object path] (--options, ...)

Examples

Read from stdin

echo '{"foo": ["bar"]}' | json-ll foo # -> ["bar"]
echo '{"foo": ["bar"]}' | json-ll foo[0] # -> bar

Read from inline

json-ll foo -f '{"foo": ["bar"]}' # -> ["bar"]
json-ll foo[0] -f '{"foo": ["bar"]}' # -> bar

Read from file

foo.yaml

foo:
  - bar
json-ll foo -f foo.yaml # -> ["bar"]
json-ll foo[0] -f foo.yaml # -> bar

Merging values

json-ll -f '{"foo": {"bar": "baz"}}' --fs foo.bar -t '{"bar": "qux"}' --ts bar # -> '{"foo": {"bar": "qux"}}'

Flags

Arguments Shorthand Input Default Description
--to -t - , /filepath, '{ "inline" : "json" }' - The source of 'to' JSON/yaml when merging. Read from stdin (-), a file (/filepath), or parse the raw --to argument ('{}').
--from -f -, /filepath, '{ "inline" : "json" }' - The source of 'from' JSON/yaml when merging. Read from stdin (-), a file (/filepath), or parse the raw --from argument ('{}')
--to-selector --ts object.path.[0].syntax The object/property path to set in the 'to' JSON
--from-selector --fs object.path[0].syntax The object/property path to take from the 'from' JSON
--value -v -, '{ "inline" : "json" }' The value to use in place of the 'from' JSON content.
--selector -s object.path.[0].syntax The object path to use when no merging is taking place.
--output-file --of /filepath The file to write the output of the command to if specified. Content is printed to stdout by default.
--keys -k false List only the keys for an object path
--newline -n false When set the newline that normally appears at the end of the output is ignored. (Don't write newline)
--spaces [-1,0,1,2,...] 3 When outputting in the JSON format the --spaces flag tells how many spaces to use for indentation. -1 for no indentation.
--output -o raw, pretty, json, yaml pretty What format to output the data in

Quirks

  • You can't escape . yet so you can't use keys with literal dots.

Readme

Keywords

Package Sidebar

Install

npm i @lafferty-lounge/json

Weekly Downloads

1

Version

0.1.3

License

WTFPL

Last publish

Collaborators

  • lafferty-lounge