# transform-json-to-html

> Transformer for TextMesh Rich Text tags

Latest version **1.1.1** (published 2022-09-29) · 0 weekly downloads

## Install

```sh
npm install transform-json-to-html
pnpm add transform-json-to-html
yarn add transform-json-to-html
bun add transform-json-to-html
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2022-09-29 |
| First published | 2022-09-29 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 47.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | ayecue |
| Maintainers | ayecue |

## Links

- npm: https://www.npmjs.com/package/transform-json-to-html
- Repository: https://github.com/ayecue/transform-json-to-html
- Issues: https://github.com/ayecue/transform-json-to-html/issues
- npm.io page: https://npm.io/package/transform-json-to-html

## Recent versions

- 1.1.1 (latest) — 2022-09-29
- 1.1.0 — 2022-09-29
- 1.0.8 — 2022-09-29
- 1.0.7 — 2022-09-29
- 1.0.6 — 2022-09-29
- 1.0.5 — 2022-09-29
- 1.0.4 — 2022-09-29
- 1.0.3 — 2022-09-29
- 1.0.2 — 2022-09-29
- 1.0.1 — 2022-09-29
- 1.0.0 — 2022-09-29

## README

# transform-json-to-html

[![transform-json-to-html](https://circleci.com/gh/ayecue/transform-json-to-html.svg?style=svg)](https://circleci.com/gh/ayecue/transform-json-to-html)

# Install

```
npm i transform-json-to-html
```

# Description

Transform JSON into a HTML tree. Inspired by [json-formatter-js](https://github.com/mohsen1/json-formatter-js).

# Usage

```js
const { transform } = require('transform-json-to-html')
const obj = {
  test: 'was',
  moo: [
    'foo',
    'bar'
  ],
  inner: {
    'bar': 1,
    inner: {
      'foo': 2
    },
    inner2: new Map([['test', 'x']]),
    inner3: new Set(['was', 'wo'])
  },
  map: new Map([['test', 'x']]),
  set: new Set(['was', 'wo'])
};

obj.cyclic = obj;

const item = transform(obj, {
  depth: 4
});

document.getElementById('root').appendChild(item);
```

# API

`transform(object [, options])`

* `object` - Any object you want to transform into HTML.
* `options` - Optional argument to define options.
  * `depth` - Max depth for traversal.
  * `itemLimit` - Limit of items to display of value.
  * `collapseDepth` - Depth from where items should be collapsed by default.
  * `theme` - CSS theme to use.
  * `parseItem` - Parse item.
  * `onCollapse` - Callback for collapse event.

Returns HTMLElement.

## Default options:

```js
{
  "depth": 2,
  "itemLimit": 100,
  "collapseDepth": 2,
  "theme": "default",
  "parseItem": (v) => v;
  "onCollapse": (ev) => {};
}
```

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