const json = {
"tag": "div",
"props":{
"className":"container"
},
"children":[
{
"tag":"h1",
"children":["Hello world"]
},
{
"tag":"p",
"props":{
"style":{
"color":"blue"
}
},
"children":["This is a paragraph"]
}
]
}
function jsonToJSX(json) {
if(!json.tag) return null;
const props = json.props || {};
const children = json.children
? json.children.map(child =>
typeof child === 'string' ? child : jsonToJSX(child))
:null;
return React.creatElement(jon.tag,props,children);
}