Json to HTML is a NodeJS package that let you convert Json to HTML.
To convert your Json, it need to looks like this
{
"element_name": {
"class": "test",
"text": "Hello there"
}
}
An element name followed by an object of properties.
In the example you have an element a
with a sub element b
with text "Click me".
The text part need to be the second lowest key in the object right before another element inside the current element.
npm install void-json-html
const HTML = require('void-json-html')
// can parse a File or an Object
// let obj = HTML.parse('./obj.json')
let obj = HTML.parseObj({
"a": {
"class": "button button-red",
"href": "#test",
"b":{
"text":"Click me"
}
}
})
console.log(obj)
// should log <a class="button button-red" href="#test"><b>Click me</b></a>