Attributes
Popular
Repository
Current version released
4 years ago
Versions
JSON Tree
Json Tree 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.
Getting it
For use with deno
import { jsonTree } from "https://deno.land/x/json_tree/mod.ts";
console.log(
jsonTree({
apples: 'gala', // ββ apples: gala
oranges: 'mandarin' // ββ oranges: mandarin
}, true)
);
CLI
Alternatively, you can use it directly from the CLI:
Read Json from local directory
deno run --allow-read https://deno.land/x/json_tree/cli.ts path sample.json
Read Json from server
deno run --allow-net https://deno.land/x/json_tree/cli.ts fetch https://jsonplaceholder.typicode.com/users
You can also install it globally using the following:
deno install --allow-net --allow-read -n jsonTree https://deno.land/x/json_tree/cli.ts
Then, the package is available to run:
jsonTree
Configuration
Required permissions:
--allow-net
--allow-read
Usage
The methods exposed to you are as follows, in a strange kind of signature notation:
jsonTree()
jsonTree(obj, showValues (boolean), hideFunctions?:bollean)
obj : json Object
showValues : To Show the object values in tree. set it true or false
hideFunctions : To Show the function in tree. set it true or false