An open API service indexing awesome lists of open source software.

https://github.com/convos-chat/jsonhtmlify

Convert JSON to HTML
https://github.com/convos-chat/jsonhtmlify

json

Last synced: 2 months ago
JSON representation

Convert JSON to HTML

Awesome Lists containing this project

README

          

## jsonhtmlify(json) ⇒ HTMLElement
`jsonhtmlify()` takes any type (object, array, string, null, ...) and converts
it to a DOM structure.

This function does not do any styling, and it does also does not provide any
click events. See the examples on [github](http://htmlpreview.github.io/?https://github.com/jhthorsen/jsonhtmlify/blob/master/examples/index.html)
for information on how to do that.

What it does however, is that it adds many classes to the DOM elements, so
you style and modify it however you like.

**Kind**: global function
**Returns**: HTMLElement - A DOM element.

| Param | Type | Description |
| --- | --- | --- |
| json | Any | An array, boolean, null, number, object or string. |

**Example**
```js
// Import the function
const {jsonhtmlify} = require('jsonhtmlify');

// true
const domNode = jsonhtmlify(true);

// 42
const domNode = jsonhtmlify(42);

// foo
const domNode = jsonhtmlify('foo');

// null
const domNode = jsonhtmlify(null);
const domNode = jsonhtmlify(undefined);

//


const domNode = jsonhtmlify([]);

//


const domNode = jsonhtmlify({});

//


//

// age36
//

//

// languagesarray[2]
//

//

// 0norwegian
//

//

// 1english
//

//

//

//

const domNode = jsonhtmlify({age: 36, languages: ['norwegian', 'english']});
```