JSON editor & viewer for Vue 2.6/2.7/3 & Nuxt 2/3.
English | 简体中文
🕹 Playground
- Support Vue 2.6/2.7/3
- Support SSR (Nuxt 2/3)
- Support Vite, Vue CLI, webpack, CDN...
- Support microfrontends (wujie, qiankun, single-spa...)
- Edit mode two-way binding
- Local registration & configuration, or global registration & configuration (Powered by vue-global-config)
- vue
- vanilla-jsoneditor: Standalone bundle provided by svelte-jsoneditor (successor to jsoneditor)
@vue/composition-api: Only for Vue 2.6 or earlier
npm i json-editor-vue vanilla-jsoneditor
<template>
<JsonEditorVue
v-model="value"
v-bind="{/* local props & attrs */}"
/>
</template>
<script setup>
import JsonEditorVue from 'json-editor-vue'
const value = ref()
</script>
import { createApp } from 'vue'
import JsonEditorVue from 'json-editor-vue'
createApp()
.use(JsonEditorVue, {
// global props & attrs (one-way data flow)
})
.mount('#app')
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
</head>
<body>
<div id="app">
<json-editor-vue v-model="value"></json-editor-vue>
</div>
<script type="importmap">
{
"imports": {
"vue": "https://unpkg.com/vue/dist/vue.esm-browser.prod.js",
"vue-demi": "https://unpkg.com/vue-demi/lib/v3/index.mjs",
"vanilla-jsoneditor": "https://unpkg.com/vanilla-jsoneditor",
"json-editor-vue": "https://unpkg.com/json-editor-vue@0.10/dist/json-editor-vue.mjs"
}
}
</script>
<script type="module">
import { createApp, ref } from 'vue'
import JsonEditorVue from 'json-editor-vue'
createApp({
setup: () => ({
value: ref()
})
}).use(JsonEditorVue)
.mount('#app')
</script>
</body>
</html>
⚠ Not yet supported because vanilla-jsoneditor does not export UMD, please leave a message here if you need it.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
</head>
<body>
<div id="app">
<json-editor-vue v-model="value"></json-editor-vue>
</div>
<script src="https://unpkg.com/vue"></script>
<script src="https://unpkg.com/vue-demi"></script>
<!-- TODO --> <script src="./vanilla-jsoneditor.umd.js"></script>
<script src="https://unpkg.com/json-editor-vue@0.10"></script>
<script>
const { createApp, ref } = Vue
createApp({
setup: () => ({
value: ref(),
}),
}).component('json-editor-vue', JsonEditorVue)
.mount('#app')
</script>
</body>
</html>
npm i json-editor-vue vanilla-jsoneditor
<template>
<JsonEditorVue
v-model="value"
v-bind="{/* local props & attrs */}"
/>
</template>
<script setup>
import JsonEditorVue from 'json-editor-vue'
const value = ref()
</script>
import Vue from 'vue'
import JsonEditorVue from 'json-editor-vue'
Vue.use(JsonEditorVue, {
// global props & attrs (one-way data flow)
})
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
</head>
<body>
<div id="app">
<json-editor-vue v-model="value"></json-editor-vue>
</div>
<script type="importmap">
{
"imports": {
"vue": "https://unpkg.com/vue@2/dist/vue.esm.browser.min.js",
"vue-demi": "https://unpkg.com/vue-demi/lib/v2.7/index.mjs",
"vanilla-jsoneditor": "https://unpkg.com/vanilla-jsoneditor",
"json-editor-vue": "https://unpkg.com/json-editor-vue@0.10/dist/json-editor-vue.mjs"
}
}
</script>
<script type="module">
import Vue from 'vue'
import JsonEditorVue from 'json-editor-vue'
new Vue({
components: { JsonEditorVue },
data() {
return {
value: undefined,
}
},
}).$mount('#app')
</script>
</body>
</html>
⚠ Not yet supported because vanilla-jsoneditor does not export UMD, please leave a message here if you need it.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
</head>
<body>
<div id="app">
<json-editor-vue v-model="value"></json-editor-vue>
</div>
<script src="https://unpkg.com/vue@2"></script>
<script src="https://unpkg.com/vue-demi"></script>
<!-- TODO --> <script src="./vanilla-jsoneditor.umd.js"></script>
<script src="https://unpkg.com/json-editor-vue@0.10"></script>
<script>
new Vue({
components: { JsonEditorVue },
data() {
return {
value: undefined,
}
},
}).$mount('#app')
</script>
</body>
</html>
npm i json-editor-vue vanilla-jsoneditor @vue/composition-api
<template>
<JsonEditorVue
v-model="value"
v-bind="{/* local props & attrs */}"
/>
</template>
<script>
import Vue from 'vue'
import VCA from '@vue/composition-api'
import JsonEditorVue from 'json-editor-vue'
Vue.use(VCA)
export default {
components: { JsonEditorVue },
data() {
return {
value: undefined,
}
},
}
</script>
import Vue from 'vue'
import VCA from '@vue/composition-api'
import JsonEditorVue from 'json-editor-vue'
Vue.use(VCA)
Vue.use(JsonEditorVue, {
// global props & attrs (one-way data flow)
})
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
</head>
<body>
<div id="app">
<json-editor-vue v-model="value"></json-editor-vue>
</div>
<script>
window.process = { env: { NODE_ENV: 'production' } }
</script>
<script type="importmap">
{
"imports": {
"vue": "https://unpkg.com/vue@2.6/dist/vue.esm.browser.min.js",
"@vue/composition-api": "https://unpkg.com/@vue/composition-api/dist/vue-composition-api.mjs",
"@vue/composition-api/dist/vue-composition-api.mjs": "https://unpkg.com/@vue/composition-api/dist/vue-composition-api.mjs",
"vue-demi": "https://unpkg.com/vue-demi/lib/v2/index.mjs",
"vanilla-jsoneditor": "https://unpkg.com/vanilla-jsoneditor",
"json-editor-vue": "https://unpkg.com/json-editor-vue@0.10/dist/json-editor-vue.mjs"
}
}
</script>
<script type="module">
import { createApp, ref } from '@vue/composition-api'
import JsonEditorVue from 'json-editor-vue'
const app = createApp({
setup: () => ({
value: ref(),
}),
})
app.use(JsonEditorVue)
app.mount('#app')
</script>
</body>
</html>
⚠ Not yet supported because vanilla-jsoneditor does not export UMD, please leave a message here if you need it.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
</head>
<body>
<div id="app">
<json-editor-vue v-model="value"></json-editor-vue>
</div>
<script src="https://unpkg.com/vue@2.6"></script>
<script src="https://unpkg.com/@vue/composition-api"></script>
<script src="https://unpkg.com/vue-demi"></script>
<!-- TODO --> <script src="./vanilla-jsoneditor.umd.js"></script>
<script src="https://unpkg.com/json-editor-vue@0.10"></script>
<script>
const { createApp, ref } = VueCompositionAPI
const app = createApp({
setup: () => ({
value: ref(),
}),
})
app.use(VueCompositionAPI)
app.component('json-editor-vue', JsonEditorVue)
app.mount('#app')
</script>
</body>
</html>
npm i json-editor-vue vanilla-jsoneditor
<!-- ~/components/JsonEditorVue.client.vue -->
<template>
<JsonEditorVue v-bind="attrs" />
</template>
<script setup>
import JsonEditorVue from 'json-editor-vue'
const attrs = useAttrs()
</script>
<template>
<client-only>
<JsonEditorVue
v-model="value"
v-bind="{/* local props & attrs */}"
/>
</client-only>
</template>
<script setup>
const value = ref()
</script>
// nuxt.config.ts
export default defineNuxtConfig({
modules: ['json-editor-vue/nuxt'],
})
<template>
<client-only>
<JsonEditorVue v-model="value" />
</client-only>
</template>
<script setup>
const value = ref()
</script>
// ~/plugins/JsonEditorVue.client.ts
import JsonEditorVue from 'json-editor-vue'
export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.vueApp.use(JsonEditorVue, {
// global props & attrs (one-way data flow)
})
})
<template>
<client-only>
<JsonEditorVue v-model="value" />
</client-only>
</template>
<script setup>
const value = ref()
</script>
npm i json-editor-vue vanilla-jsoneditor
// nuxt.config.js
export default {
build: {
extend(config) {
// Getting webpack to recognize the `.mjs` file
config.module.rules.push({
test: /\.mjs$/,
include: /node_modules/,
type: 'javascript/auto',
})
},
},
}
<template>
<client-only>
<JsonEditorVue
v-model="value"
v-bind="{/* local props & attrs */}"
/>
</client-only>
</template>
<script setup>
import { ref } from 'vue'
const JsonEditorVue = () => process.client
? import('json-editor-vue')
: Promise.resolve({ render: (h) => h('div') })
const value = ref()
</script>
// nuxt.config.js
export default {
plugins: ['~/plugins/JsonEditorVue.client'],
build: {
extend(config) {
// Getting webpack to recognize the `.mjs` file
config.module.rules.push({
test: /\.mjs$/,
include: /node_modules/,
type: 'javascript/auto',
})
},
},
}
// ~/plugins/JsonEditorVue.client.js
import Vue from 'vue'
import JsonEditorVue from 'json-editor-vue'
Vue.use(JsonEditorVue, {
// global props & attrs (one-way data flow)
})
<template>
<client-only>
<JsonEditorVue v-model="value" />
</client-only>
</template>
<script setup>
import { ref } from 'vue'
const value = ref()
</script>
npm i json-editor-vue vanilla-jsoneditor @vue/composition-api
// nuxt.config.js
export default {
build: {
extend(config) {
// Getting webpack to recognize the `.mjs` file
config.module.rules.push({
test: /\.mjs$/,
include: /node_modules/,
type: 'javascript/auto',
})
},
},
}
<template>
<client-only>
<JsonEditorVue
v-model="value"
v-bind="{/* local props & attrs */}"
/>
</client-only>
</template>
<script>
import Vue from 'vue'
import VCA from '@vue/composition-api'
Vue.use(VCA)
export default {
components: {
JsonEditorVue: () => process.client
? import('json-editor-vue')
: Promise.resolve({ render: (h) => h('div') }),
},
data() {
return {
value: undefined,
}
},
}
</script>
// nuxt.config.js
export default {
plugins: ['~/plugins/JsonEditorVue.client'],
build: {
extend(config) {
// Getting webpack to recognize the `.mjs` file
config.module.rules.push({
test: /\.mjs$/,
include: /node_modules/,
type: 'javascript/auto',
})
},
},
}
// ~/plugins/JsonEditorVue.client.js
import Vue from 'vue'
import VCA from '@vue/composition-api'
import JsonEditorVue from 'json-editor-vue'
Vue.use(VCA)
Vue.use(JsonEditorVue, {
// global props & attrs (one-way data flow)
})
<template>
<client-only>
<JsonEditorVue v-model="value" />
</client-only>
</template>
<script>
export default {
data() {
return {
value: undefined,
}
},
}
</script>
Ready to use right out of the box.
Ready to use right out of the box.
Vite 4 (Rollup 3) uses ES2020 as compiler target by default, therefore Vite-4-built outputs should be transpiled in webpack 4.
≥ v4.5.15
// vue.config.js
module.exports = {
transpileDependencies: ['json-editor-vue'],
}
< v4.5.15
// vue.config.js
module.exports = {
transpileDependencies: ['json-editor-vue'],
configureWebpack: {
module: {
rules: [
// Getting webpack to recognize the `.mjs` file
{
test: /\.mjs$/,
include: /node_modules/,
type: 'javascript/auto',
},
],
},
},
}
Vite 4 (Rollup 3) uses ES2020 as compiler target by default, therefore Vite-4-built outputs should be transpiled in webpack 4.
npm i @babel/plugin-proposal-nullish-coalescing-operator @babel/plugin-proposal-optional-chaining -D
// babel.config.js
module.exports = {
plugins: [
'@babel/plugin-proposal-nullish-coalescing-operator',
'@babel/plugin-proposal-optional-chaining',
],
}
// vue.config.js
module.exports = {
transpileDependencies: ['json-editor-vue'],
chainWebpack(config) {
// Getting webpack to recognize the `.mjs` file
config.module
.rule('mjs')
.include.add(/node_modules/)
.type('javascript/auto')
.end()
},
}
Vue CLI 2 & 1 pull the template from vuejs-templates/webpack.
npm i @babel/core@latest @babel/preset-env@latest babel-loader@latest -D
// babel.config.js
module.exports = {
presets: [
'@babel/preset-env',
],
}
// webpack.base.conf.js
module.exports = {
module: {
rules: [
// Getting webpack to recognize the `.mjs` file
{
test: /\.mjs$/,
loader: 'babel-loader',
include: [resolve('src'), resolve('test'), resolve('node_modules/json-editor-vue')],
},
],
},
}
Name | Description | Type | Default |
---|---|---|---|
v-model / modelValue (Vue 3) / value (Vue 2) |
binding value | any | |
mode / v-model:mode (Vue 3) / :mode.sync (Vue 2) |
edit mode | Mode | 'tree' |
... | properties of svelte-jsoneditor |
⚠ kebab-case is required for tag & prop name when using from CDN.
- svelte-jsoneditor: An object contains a stringified JSON or a parsed JSON, will do
JSON.parse
when passing as a stringified JSON. - json-editor-vue: JSON itself. What you see is what you get.
If you prefer the behavior of svelte-jsoneditor:
<JsonEditorVue
:content="content"
:onChange="(updatedContent) => {
content = updatedContent
}"
/>
See josdejong/svelte-jsoneditor#166 for more details.
Including the boolean properties of svelte-jsoneditor like readOnly
with no value will imply true
:
-
✔️
<JsonEditorVue readOnly />
-
✔️
<JsonEditorVue :readOnly="true" />
Name | Description | Type |
---|---|---|
jsonEditor | JSONEditor instance | object |
type Mode = 'tree' | 'text' | 'table'
<template>
<JsonEditorVue class="jse-theme-dark" />
</template>
<script setup>
import 'vanilla-jsoneditor/themes/jse-theme-dark.css'
import JsonEditorVue from 'json-editor-vue'
</script>
Detailed changes for each release are documented in the release notes.
- Install Deno
- Run
npm i -g @cloydlau/scripts
- Run
cl i
and choose pnpm - Run
cl dev3
/cl dev2.7
/cl dev2.6