j2t

command module
v0.0.0-...-06c2b72 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2024 License: MIT Imports: 10 Imported by: 0

README

j2t

A simple utility to extract a structure from JSON. Made this to list all fields in a JSON string for further processing in jq

Usage

usage: j2t [-h|--help] [-o|--output "<value>"] [-i|--input "<value>"]
           [-f|--format (list|json|csv)] [-P|--prefix "<value>"] [-H|--headers]
           [-m|--merge] [-n|--numeric]

           A simple utility to extract a structure from JSON

Arguments:

  -h  --help     Print help information
  -o  --output   Sets the output file. Reads from STDIN by default
  -i  --input    Sets the input file. Writes to STDOUT by default
  -f  --format   Output format. Default: list
  -P  --prefix   Field prefix
  -H  --headers  If headers should be printed
  -m  --merge    Merges type and content for fields with multiple types
  -n  --numeric  Categorize `number` into `number_int` and `number_float`

Simple usage

➜  echo '{"name": "Sam","dislikes": [{"name": "eggs", "color": "green"}, "Ham"]}' | j2t
.dislikes.[]       string "Ham"
.dislikes.[].color string "green"
.dislikes.[].name  string "eggs"
.name              string "Sam"

Print CSV with headers

➜  echo '{"name": "Sam","dislikes": [{"name": "eggs", "color": "green"}, "Ham"]}' | j2t -f csv -H
field,type,content
.dislikes[],string,"""Ham"""
.dislikes[].color,string,"""green"""
.dislikes[].name,string,"""eggs"""
.name,string,"""Sam"""

Supports multi-type arrays

➜  echo '[1, "two"]' | j2t
[]    string     "two"
[]    number 1

Packages

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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