
Product
Introducing Webhook Events for Alert Changes
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.
npm
npm install jsx-parser
how to require
import JSXParser form 'index'
or
<script src="index.umd"></script
how to use
var str = '<div><div id={ 2222 } kkk={<div/>} class="{111}" >xxx{[1,2,3,4].map(function(el){ return <div ref=3 >{el}</div> })}22</div><div><div ref=111>{55}</div></div></div>'
// 用渲染函数构建虚拟模版类
var array = (new JSXParser(str)).parse()
console.log(JSON.stringify(array))
output
[
{
"type": "div",
"props": { },
"children": [
{
"type": "div",
"props": {
"id": {
"type": "#jsx",
"nodeValue": " 2222 "
},
"kkk": {
"type": "#jsx",
"nodeValue": [
{
"type": "div",
"props": { },
"children": [ ],
"isVoidTag": true
}
]
},
"class": "{111}"
},
"children": [
{
"type": "#text",
"nodeValue": "xxx"
},
{
"type": "#jsx",
"nodeValue": [
{
"type": "#jsx",
"nodeValue": "[1,2,3,4].map(function(el){ return "
},
{
"type": "div",
"props": {
"ref": "3"
},
"children": [
{
"type": "#jsx",
"nodeValue": "el"
}
]
},
{
"type": "#jsx",
"nodeValue": " })"
}
]
},
{
"type": "#text",
"nodeValue": "22"
}
]
},
{
"type": "div",
"props": { },
"children": [
{
"type": "div",
"props": {
"ref": "111"
},
"children": [
{
"type": "#jsx",
"nodeValue": "55"
}
]
}
]
}
]
}
]

var a = new JSXParser('<div id={22} class="ddd" {...{a:1,b:2}}>111</div>')
console.log(a)

FAQs
a simple jsx parser
We found that jsx-parser demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.

Security News
ENISA has become a CVE Program Root, giving the EU a central authority for coordinating vulnerability reporting, disclosure, and cross-border response.

Product
Socket now scans OpenVSX extensions, giving teams early detection of risky behaviors, hidden capabilities, and supply chain threats in developer tools.