Attributes
Includes Deno configuration
Repository
Current version released
2 years ago
Dependencies
std
jsontree
jsontree
converts a JS object into a nice, visible depth-indented tree for
console printing. The structure generated is similar to what you get by running
the tree
command on Unixy platforms.
{
oranges: {
'mandarin': { ββ oranges
clementine: null, β ββ mandarin
tangerine: 'so cheap and juicy!' -=> β ββ clementine
} β ββ tangerine: so cheap and juicy!
}, ββ apples
apples: { ββ gala
'gala': null, ββ pink lady
'pink lady': null
}
}
It also works well with larger nested hierarchies such as file system directory trees.
Quick start
Programmatic
import { jsonTree } from "https://deno.land/x/jsontree@{VERSION}/mod.ts";
console.log(
jsonTree({
apples: "gala", // ββ apples: gala
oranges: "mandarin", // ββ oranges: mandarin
}),
);
CLI
Alternatively, you can use it directly from the CLI:
Read JSON from local directory
deno run --allow-read https://deno.land/x/jsontree@1.0.0/cli.ts path sample.json
Read JSON from server
deno run --allow-net https://deno.land/x/jsontree@1.0.0/cli.ts fetch https://jsonplaceholder.typicode.com/users
Install globally
deno install --allow-net --allow-read -n jsontree https://deno.land/x/jsontree@1.0.0/cli.ts
Then, the binary is available to run:
jsontree
Configuration
Required permissions:
--allow-net
(if using clifetch
option)--allow-read
(if using clipath
option or programmatic API)
Usage
jsonTree(obj, { showValues?: boolean })
Where:
obj
: json objectshowValues
: whether or not to show the object values in the tree
Screenshots
With Values
Without Values
Acknowledgement
This is a fork of the original satty1987/json_tree module.