o-family

o-family o-json

o-json

A JSON structure and table viewer: every path with its types and counts, arrays of objects as tables, and restructure, query with jq and export.

toolv0.4.5early

o-json sample.jsonrec
An array of objects as a table in the o-json viewer

An array of objects as a table in the o-json viewer

overview

What it is

o-json answers two questions about a document: what shape is it (every path, its types, how many values have it, which fields are optional), and what does an array of objects look like as a table. Built on ochazuke with an oden command line.

It never writes the document it reads unless asked: restructure, export and the viewer's write make a new file, and replace an existing one only with --overwrite, or W on the page, which confirms first.

install

build
git clone https://github.com/unixsuperhero/o-json && cd o-json && go build -o ~/bin/o-json .
the command linesh
o-json data.json                        # open the viewer
curl -s https://... | o-json            # or read stdin
o-json structure data.json              # the shape as a tree
o-json table data.json .items           # an array as a table
o-json query data.json '.items[] | .name'
o-json export data.json --of .items > items.csv

features

What it does

  1. 01 / 06

    Structure

    One pass records, for every [] path, the types seen, how many values have it and which fields are optional. Duplicate keys are flagged the way jq reads them.

  2. 02 / 06

    Tables

    An array becomes one row per item and one column per key, optional columns last and marked ?. A missing field is a blank cell, not null.

  3. 03 / 06

    Query with jq

    Runs jq through gojq, pure Go, no jq binary needed. Path expressions print the document's own values in document order.

  4. 04 / 06

    Restructure

    Map shape paths to a new document, add value patches and reshape steps; --jq prints a jq program that makes the same document and never fails on that shape.

  5. 05 / 06

    Export

    An array to csv, tsv, jsonl or markdown, from the CLI or the viewer.

  6. 06 / 06

    Safe by default

    Edits live in the viewer with undo; nothing touches the source file unless you ask to replace it.

o-json structure testdata/sample.jsonconsole
.               object         1
  name          string       1/1
  items         array        1/1  4 items
    []          object         4
      id        number       4/4
      owner     object       4/4
        email   string|null  2/4  optional
      tags      array        4/4  0..2 items
      archived  bool         1/4  optional

the guide, in eight recordings

Task by task

Each recording is a chapter of the o-json guide.