HTML Represented using JSON.
{
"html": [
{ "head": [] },
{
"body": [
"Plain Text...",
{ "p": "Hello, World!" },
"<img src='https://www.w3.org/Icons/w3c_home'/>"
],
"style": "color:red;"
}
]
}
<!DOCTYPE html><html><head></head><body style='color:red;'>Plain Text...<p>Hello, World!</p><img src='https://www.w3.org/Icons/w3c_home'/></body></html>
The first key in a JSON object is interpreted as the element name. e.g. div
or p
or body
.
Any other keys are interpreted as element attributes.
The value of the first key is either a string (for textContent) or an array of other elements or strings (interpreted as inline html). Single tags can be used by using the string as an element e.g.
{
"div": [
"<img src='hi.png'/>"
]
}