
Security News
The Hidden Blast Radius of the Axios Compromise
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.
@bagaking/jsoneditor
Advanced tools
一个功能强大的 JSON 编辑器组件,支持 JSON Schema 验证、路径高亮、主题切换、自定义操作等功能。
🎨 主题系统
🔍 智能编辑
✨ Schema 支持
🎯 状态栏
💡 开发友好
pnpm add @bagaking/jsoneditor
# 或
npm install @bagaking/jsoneditor
# 或
yarn add @bagaking/jsoneditor
import { JsonEditor } from '@bagaking/jsoneditor';
function App() {
return (
<JsonEditor
defaultValue={'{"hello": "world"}'}
themeConfig={{ theme: 'light' }}
onValueChange={setValue}
onError={setError}
// 编辑器配置
codeSettings={{
fontSize: 14,
lineNumbers: true,
bracketMatching: true
}}
// 主题配置
themeConfig={{
theme: 'light'
}}
/>
);
}
或者克隆仓库本地运行:
git clone https://github.com/bagaking/jsoneditor.git
cd jsoneditor
pnpm install
pnpm dev
本组件使用 JSON Schema 进行数据验证和自动补全。支持 Draft 2020-12 规范。
import { JsonEditor } from '@bagaking/jsoneditor';
const schema = {
type: 'object',
properties: {
name: {
type: 'string',
description: '项目名称',
minLength: 1
},
version: {
type: 'string',
pattern: '^\\d+\\.\\d+\\.\\d+$',
description: '版本号 (Semver)'
}
},
required: ['name', 'version']
};
function App() {
return (
<JsonEditor
defaultValue={JSON.stringify({
name: 'my-project',
version: '1.0.0'
}, null, 2)}
schemaConfig={{
schema,
validateOnType: true
}}
/>
);
}
更多用法请参考 Schema 验证指南。
支持为不同的 JSON 路径添加自定义样式和交互:
import { JsonEditor } from '@bagaking/jsoneditor';
function App() {
return (
<JsonEditor
defaultValue={value}
decorationConfig={{
paths: {
// 版本号使用特殊样式
'$["version"]': {
style: "italic bg-blue-100/30 rounded px-1",
onClick: (value) => console.log('Version:', value)
},
// 状态使用不同颜色
'$["status"]': {
style: "text-green-600 font-medium"
}
}
}}
/>
);
}
更多用法请参考 装饰系统文档。
import { JsonEditor, EditorCore } from '@bagaking/jsoneditor';
import { useRef } from 'react';
function App() {
const editorRef = useRef<EditorCore>(null);
const handleFormat = () => {
const value = editorRef.current?.getValue();
if (value) {
editorRef.current?.setValue(
JSON.stringify(JSON.parse(value), null, 2)
);
}
};
return (
<>
<button onClick={handleFormat}>格式化</button>
<JsonEditor
ref={editorRef}
defaultValue={value}
onValueChange={setValue}
/>
</>
);
}
欢迎提交 Issue 或 Pull Request!
FAQs
A powerful JSON editor with schema validation
We found that @bagaking/jsoneditor demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers 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.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.