# vue-json-tree-view

> a JSON Tree View Component in Vue.js

Latest version **2.1.6** (published 2020-02-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install vue-json-tree-view
pnpm add vue-json-tree-view
yarn add vue-json-tree-view
bun add vue-json-tree-view
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 2.1.6 |
| Published | 2020-02-25 |
| First published | 2017-02-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 165 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 473 |
| Author | Arvid Kahl |
| Maintainers | arvidkahl, michaelfitzhavey |
| Keywords | vue-component, vuejs |

## Links

- npm: https://www.npmjs.com/package/vue-json-tree-view
- Repository: https://github.com/michaelfitzhavey/vue-json-tree-view
- Issues: https://github.com/michaelfitzhavey/vue-json-tree-view/issues
- npm.io page: https://npm.io/package/vue-json-tree-view

## Dependencies (2)

- [vue](https://npm.io/package/vue.md) ^2.5.16
- [lodash](https://npm.io/package/lodash.md) ^4.17.4

## Recent versions

- 2.1.6 (latest) — 2020-02-25
- 2.1.5 — 2020-02-25
- 2.1.4 — 2018-04-21
- 2.1.3 — 2018-01-13
- 2.1.2 — 2018-01-11
- 2.1.1 — 2017-08-14
- 2.1.0 — 2017-08-14
- 2.0.7 — 2017-04-19
- 2.0.6 — 2017-04-08
- 2.0.5 — 2017-04-07
- 2.0.4 — 2017-04-07
- 2.0.3 — 2017-02-19
- 2.0.2 — 2017-02-19
- 2.0.1 — 2017-02-19
- 2.0.0 — 2017-02-19
- … 16 more at https://npm.io/package/vue-json-tree-view/versions

## README

# Vue JSON Tree View

![a demonstration](https://raw.githubusercontent.com/arvidkahl/vue-json-tree-view/master/header.png)

## Demo and Blogpost

You can check out the [demo](https://jsfiddle.net/arvidkahl/kwo6vk9d/11/) on JSFiddle and read the Blogpost called [Building a JSON Tree View Component in Vue.js from Scratch in Six Steps](http://brianyang.com/building-a-json-tree-view-component-in-vue-js-from-scratch-in-six-steps) that lead to the creation of this library.

##  Installation

Install the plugin with npm:
```shell
npm install --save vue-json-tree-view
```

Then, in your Application JavaScript, add:
```javascript
import TreeView from "vue-json-tree-view"
Vue.use(TreeView)
```

Done.

## Usage

Put the `tree-view` element into your  HTML where you want the Tree View to appear.
```html
<div>
  <tree-view :data="jsonSource" :options="{maxDepth: 3}"></tree-view>
</div>
```

## Props

#### `data`

The JSON to be displayed. Expects a valid JSON object.

#### `options`

The defaults are:
```
{
  maxDepth: 4,
  rootObjectKey: "root",
  modifiable: false,
  link: false,
  limitRenderDepth: false
}
```
- maxDepth: The maximum number of levels of the JSON Tree that should be expanded by default. Expects an Integer from 0 to Infinity.
- rootObjectKey: the name of the Root Object, will default to `root`.
- modifiable: To modify the json value.
- link: URL strings will appear as clickable links (unless `modifiable="true"`).
- limitRenderDepth: maximum number of nodes that should be rendered (for very large JSONs)

## Event

#### updated json data
If `modifiable` is true and you want to take the updated json data, you must register event handler as `v-on:change-data=...`. Only one argument is passed that is updated data - `data`.
```html
<div>
  <tree-view :data="jsonSource" :options="{modifiable: true}" @change-data="onChangeData"></tree-view>
</div>

// in your vue code
  ...
  methods: {
    onChangeData: function(data) {
      console.log(JSON.stringify(data))
    }
  },
  ...

```


## Custom Styling

All leaves will have their type indicated as a CSS class, like `tree-view-item-value-string`. Supported types: String, Number, Function, Boolean and Null Values.

Keys can also be styled. For instance to make labels red:
```
.tree-view-item-key {
    color: red;
}
```

## Contributing
Contributions to this repo are very welcome as they are what has helped it become what it is today. Simply raise an issue with new ideas or submit a pull request.

A github action automatically deploys changes when they are merged into the master branch.

---
_Source: https://npm.io/package/vue-json-tree-view · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
