I have a POC to deliver which entitle to convert html content into a json file. This means the json file needs to be in a specific format which I can't figure out how to display it. I have not working out how to format the nodeChild elements in the format requested, so I need help on this matter.
This is the HTML content:
<body>
<style>
.myclass{padding-top:50px; left:0;}
</style>
<div id="maincontent">
<div id="myid">
<p class="myclass">
This is a paragraph
</div>
</div>
</body>
And this is the .json format I need to be expelled out from the HTML content:
"t" stands for "type:, "s" stands for "style" and "h" stands for "html"
[
{
"t": "s",
"s": ".myclass{padding-top:50px; left:0;}"
},
{
"t": "h",
"h": "<div id='myid'><p class='myclass'>This is a paragraph</p></div>"
}]
At the moment the file generated looks like this. But I need to place all the content in an unique line and not separated.
{
"t": "DIV",
"content": [{
"t": "DIV",
"content": ["This is a paragraph"],
"s": {
"class": "myclass"
}
}],
}
Any help will be appreciated.