Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
magic-json-tree
Advanced tools
npm install --save magic-json-tree
In your Svelte app:
<script>
import Tree from 'magic-json-tree'
const json = {
name: 'john',
age: 123,
male: true,
pets: ['rat', 'flees'],
inventory: {
belt: ['coins', 'knife', 8, undefined],
backpack: null,
},
skills: new Map([
['strength', 123],
[456, ['one', 'two', 'three']],
[['favourite', 'inputs'], { taste: 'apple', smell: 'banana' }],
]),
}
</script>
<Tree value={json} />
This renders a tree view:
Name | Type | Default | Description |
---|---|---|---|
expand | number | (string | number)[] | 0 | Pass a number to expand that many levels deep OR pass an object path like ['item', 'subItem', 'subSubItem'] |
formatKey | ([any, any], path: any[]) => any | null | Pass a function to format object keys. The function is passed [key, value] as its first parameter, and an object path as its second (e.g. ['item', 'subItem', 2, 'subSubItem'] ) |
formatValue | ([any, any], path: any[]) => any | null | Pass a function to format object values. The function is passed [key, value] as its first parameter, and an object path as its second (e.g. ['item', 'subItem', 2, 'subSubItem'] ) |
Execute npm run dev
and open the given URL in your browser.
You can set some of the following CSS variables to overwrite the default colors:
--mjt-color-key: var(--base1);
--mjt-color-string: var(--orange);
--mjt-color-number: var(--cyan);
--mjt-color-null: var(--yellow);
--mjt-color-undefined: var(--yellow);
--mjt-color-boolean: var(--blue);
--mjt-color-object: var(--base1);
--mjt-color-array: var(--base1);
--mjt-color-symbol: var(--green);
--mjt-color-map: var(--green);
--mjt-color-set: var(--green);
FAQs
magic-json-tree Svelte component to render interactive JSON trees.
The npm package magic-json-tree receives a total of 7 weekly downloads. As such, magic-json-tree popularity was classified as not popular.
We found that magic-json-tree demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.