Skip to content

Text JSON

Vali (naser) Rafinia edited this page Mar 27, 2023 · 4 revisions

nhash is a command-line tool that provides various text utilities, including JSON tools. The json sub-command allows you to process JSON text, convert it to other formats, and print it in a pretty or compact format.

Usage

nhash text json [<text>] [options]

Arguments

  • <text>: JSON text for processing.

Options

  • --print <Compact|Pretty>: Print the JSON representation in a pretty or compact format.
  • -f, --file <file>: File name for reading JSON from.
  • -c, --convert <JSON|XML|YAML>: Convert the JSON text to other formats (YAML or XML).
  • -o, --output <output>: File name for writing the output.
  • -?, -h, --help: Show help and usage information.

Examples

  1. Process JSON text:
nhash text json '{"name": "John Doe", "age": 30}'
  1. Read JSON from a file:
nhash text json -f data.json
  1. Convert JSON to YAML:
nhash text json '{"name": "John Doe", "age": 30}' -c yaml
  1. Write the output to a file:
nhash text json '{"name": "John Doe", "age": 30}' --output output.txt
  1. Print pretty JSON representation:
nhash text json '{"name": "John Doe", "age": 30}' --print pretty
  1. Print compact JSON representation:
nhash text json '{"name": "John Doe", "age": 30}' --print compact
Clone this wiki locally