You are here: Home » NewsFeeds » json_schema: a jq wrapper that prints back a high-level view of a JSON document

json_schema: a jq wrapper that prints back a high-level view of a JSON document

README.md

A wrapper for jq. Dumps the schemas
(as determined by jq) from a JSON document.
A jq wrapper that prints back a high-level view of the schema of a
JSON document.
json_schema is a bash script that does two things:
List unique paths (using pseudocode).
Count how many times each unique path occurs.
List the unique paths in a JSON document
Each unique path in the JSON document is printed alongside a count of
how many times that unique path occurs in the document.
Count how many times each unique path occurs
For each unique path, a count of occurrences is printed to the left
of the path.

Use it like this:
json_schema foo.json

If the contents of foo.json were the following:
{
“a”: “foo”,
“b”: “bar”,
“c”: [1, 2, 3, {“hello”: “world”}, 4, 5],
“d”: []
}

Then that should produce output like this:
1 a
1 b
1 c
6 c.[n]
1 c.[n].hello
1 d

Sample output from NASA near-Earth objects report
This is


 

Original article