# simple-json-viewer

[![](https://badgen.net/packagephobia/install/simple-json-viewer)](https://packagephobia.com/result?p=simple-json-viewer)
[![](https://img.shields.io/npm/v/simple-json-viewer)](https://www.npmjs.com/package/simple-json-viewer)
[![Published on webcomponents.org](https://img.shields.io/badge/webcomponents.org-published-blue.svg)](https://www.webcomponents.org/element/simple-json-viewer)

A simple web component to display JSON data.

# Usage

Plain HTML

```html
<script type="module" src="https://unpkg.com/simple-json-viewer"></script>

<json-viewer data='{"some": "json", "array": [0, true, "2"] }'></json-viewer>
```

With JavaScript

```js
import "https://unpkg.com/simple-json-viewer";

const jv = document.createElement("json-viewer");
// data can be any JavaScript variable that can be stringified to JSON
jv.data = { some: "json", array: [0, true, "2"] };
document.body.append(jv);

// You can also expand all or collapse all
jv.expandAll();
jv.collapseAll();
```
