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
- Host: GitHub
- URL: https://github.com/convos-chat/jsonhtmlify
- Owner: convos-chat
- Created: 2019-08-03T18:09:14.000Z (almost 7 years ago)
- Default Branch: main
- Last Pushed: 2025-03-11T22:33:15.000Z (over 1 year ago)
- Last Synced: 2025-10-30T07:24:16.352Z (8 months ago)
- Topics: json
- Language: JavaScript
- Homepage: http://htmlpreview.github.io/?https://github.com/jhthorsen/jsonhtmlify/blob/master/examples/index.html
- Size: 655 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
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']});
```