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

https://github.com/yoannchb-pro/json-html

Convert json to html
https://github.com/yoannchb-pro/json-html

converter html json

Last synced: 2 months ago
JSON representation

Convert json to html

Awesome Lists containing this project

README

          

# json-into-html v1.0.0
Convert json to html

## Installation
```
npm i json-into-html
```

## Example
```js
const { Json2Html } = require('json-into-html');
const fs = require("fs");

const html = Json2Html([
{
name: "html",
content: [
{
name: 'head',
content: [
{
name: 'title',
content: "My title"
},
{
name: "style",
content: "body,html{ margin: 0; paddin: 0; display: flex; justify-content: center; align-items: center; height: 100vh; flex-direction: column; color: #fff; font-familly: Arial, 'sans-serif'; background-color: #663399}"
}
]
},
{
name: 'body',
content: [
{
name: 'div',
content: [
{
name: 'img',
attr: {
src: 'https://upload.wikimedia.org/wikipedia/commons/d/d9/Flag_of_Canada_%28Pantone%29.svg',
class: 'test test2'
}
},
{
name: 'a',
content: 'click here',
attr: {
href: '#'
}
}
]
}
]
}
]
}
]);

fs.writeFileSync('index.html', html);
```

## Result
```html


My title

body,html{ margin: 0; paddin: 0; display: flex; justify-content: center; align-items: center; height: 100vh; flex-direction: column; color: #fff; font-familly: Arial, 'sans-serif'; background-color: #663399}





click here

```