json

package
v0.0.0-...-345b6a2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 6, 2021 License: MIT Imports: 12 Imported by: 0

README

json

output a pretty json

Usage

$ show json -h
NAME:
   show json - json beautify output

USAGE:
   show json [command options] [arguments...]

DESCRIPTION:
   display file or remote json data, you can display the json data you need by specifying the json field key,
   if you don’t specify the key, the complete json data will be displayed
   eg:
   show json --remote https://raw.githubusercontent.com/anqiansong/show/main/testdata/data.json data.user.name
   show json --file data.json

OPTIONS:
   --remote value, -r value  show json from remote
   --file value, -f value    show json from file
   --help, -h                show help (default: false)
Example
output pretty json data from remote
$ show json --remote https://raw.githubusercontent.com/anqiansong/show/main/testdata/data.json
{
  "code": 0,
  "data": {
    "user": {
      "company": "ByteDance",
      "desc": "none",
      "name": "keson"
    }
  },
  "msg": "ok"
}
specified json key
$ show json --remote https://raw.githubusercontent.com/anqiansong/show/main/testdata/data.json data.user.name
"keson"
from file
$ show json --file data.json data
{
  "user": {
    "name": "keson"
  }
}
$ show json --file data.json data.user
{
  "name": "keson"
}
from linux channel
$ cat data.json
{
  "data":{
    "user":{
      "name":"keson"
    }
}
$ cat data.json | show json data.user
{
  "name": "keson"
}

Preview

toml highlight output

  • os: macOS
  • terminal: iTerm
  • theme: atom_bold_italic json-highlighting

Documentation

Overview

Package json is used to beautify the json output. The json data can come from files, networks and linux pipelines, such as: show json --file data.json data.name means to view the data.name in the data.json file, show json --remote https://raw.githubusercontent.com/anqiansong/show/main/testdata/data.json data.user.name means to view the data.user.name in data.json, echo'{"name":"foo"}' | show json name means to view the data which json key is name

Index

Constants

This section is empty.

Variables

View Source
var Command = &cli.Command{
	Name:  "json",
	Usage: "json beautify output",
	Description: "display a file or remote json data, you can display the json data you need by specifying the json field key, \n" +
		"if you don’t specify the key, the complete json data will be displayed\n" +
		"eg:\n" +
		"show json --remote https://raw.githubusercontent.com/anqiansong/show/main/testdata/data.json data.user\n" +
		"show json --file data.json",
	Action: actionJson,
	Flags: []cli.Flag{
		&cli.StringFlag{
			Name:    "remote",
			Usage:   "show json from remote",
			Aliases: []string{"r"},
		},
		&cli.StringFlag{
			Name:    "file",
			Usage:   "show json from file",
			Aliases: []string{"f"},
		},
	},
}

Command describes a subcommands in application.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL